PHP Tutorial · PHP Basics · Lesson 1 of 38

PHP Introduction

What PHP is, how it powers the web and what you can build with it.

What is PHP?

PHP is a server-side scripting language designed for the web. It runs on the server, builds an HTML page (or JSON for an API), and sends the result to the browser — visitors never see the PHP code itself.

PHP powers a huge share of the web: WordPress, Wikipedia, and countless shops and business apps. Modern frameworks like Laravel and Symfony make it a productive choice for new projects too.

Your first PHP script

PHP code lives between <?php and ?> tags (in a file containing only PHP, leave out the closing ?>). echo outputs text:

Hello, World!Try it yourself
<?php
echo "Hello, World!";

Output

Hello, World!

Modern PHP

PHP 8 brought a JIT compiler, named arguments, union types, match, enums, readonly properties and much more. This tutorial teaches PHP 8.3 — the examples run in your browser using PHP compiled to WebAssembly.

Test yourself

Where does PHP code run?

  1. In the browser
  2. On the server
  3. In the database
  4. In CSS
Show answer

Answer: On the server

PHP runs on the web server and sends the generated HTML or JSON to the browser.