PHP syntax basics:

  • All keywords (e.g. if, else, while, echo, etc.), classes, functions, and user-defined functions are NOT case-sensitive.
  • All variable names are case-sensitive.

Example:

<!DOCTYPE html>
<html>
<body>

<h1>My first PHP page</h1>

<?php

// single-line comment​  1
# single-line comment 2
/* Multiple-lines comment - Line 1

Multiple-lines comment - Line 2

Multiple-lines comment - Line 3
*/​
echo "Hello World!";
?>

<?php
ECHO "Hello World!<br>";
echo "Hello World!<br>";
EcHo "Hello World!<br>";
?>

<?php
$color = "red";
echo "My car is " . $color . "<br>";
echo "My house is " . $COLOR . "<br>";
echo "My boat is " . $coLOR . "<br>";
?> ​

</body>
</html>

Note: PHP statements end with a semicolon (;).