← PHP tutorial

PHP

Introduction to PHP

PHP runs on the server, not in the browser — it generates HTML which then gets sent to the visitor, who never sees the PHP code itself, only its output. It powers a huge share of the web (WordPress, for one).

Example: the basic syntax

<?php
  echo "Hello, world!";
?>
Hello, world!

PHP code lives between <?php and ?> tags — everything outside those tags is treated as plain HTML and passed through untouched, which is why PHP files commonly mix real HTML markup with chunks of PHP logic in the same file. echo outputs text, and statements end with a semicolon.

Example
<?php
  echo "Hello, world!";
?>
Output
Hello, world!