Basic PHP Syntax
Everything in a PHP script runs on the server, and the browser only ever receives the resulting plain HTML. You can put a script anywhere in a document. It opens with <?php and closes with ?>.
PHP files use .php as their default extension, and most of them mix HTML tags with PHP code.
Note: Every PHP statement has to finish with a semicolon (;).
Example
Here is a small .php file that mixes HTML with a line of PHP:
Output: PHP script
<!DOCTYPE html>
<html>
<body>
<h1>My first PHP page</h1>
<?php
echo 'Hello World!';
?>
</body>
</html>
PHP script tags
These tags mark the beginning and the end of a block of PHP code:
<?php
// PHP code goes here
?>
PHP Case Sensitivity
PHP doesn't care about letter case in its keywords (such as if, else and echo), in class names or in function names, including the functions you write yourself. Variables are the exception: their names always have to match exactly, capitals included.
ECHO is the same as echo
Both spellings below are valid and print the same text, because ECHO and echo are the same keyword:
Output: PHP script
<!DOCTYPE html>
<html>
<body>
<?php
ECHO 'Hello World!<br>';
echo 'Hello World!<br>';
?>
</body>
</html>
$COLOR is not same as $color
Here $color has a value, but $COLOR is a separate variable that was never set, so it adds no text after "My house is":
Output: PHP script
<!DOCTYPE html>
<html>
<body>
<?php
$color = "red";
echo "My car is $color<br>";
echo "My house is $COLOR";
?>
</body>
</html>