Standard PHP Syntax

PHP script starts with the <?php and ends with the ?> tag.

The PHP delimiter <?php and ?> in the following example simply tells the PHP engine to treat the enclosed code block as PHP code, rather than simple HTML.

Ex:

Embedding PHP within HTML

PHP files are plain text files with .php extension. Inside a PHP file you can write HTML like you do in regular HTML pages as well as embed PHP codes for server side execution.

Ex:




    
    A Simple PHP File


    

PHP Comments

A comment is simply text that is ignored by the PHP engine. The purpose of comments is to make the code more readable. It may help other developer (or you in the future when you edit the source code) to understand what you were trying to do with the PHP.

PHP support single-line as well as multi-line comments. To write a single-line comment either start the line with either two slashes (//) or a hash symbol (#). For example:

Ex:


Case Sensitivity in PHP

Variable names in PHP are case-sensitive. As a result the variables $color, $Color and $COLOR are treated as three different variables.

Ex:

";
echo "The color of the sky is " . $Color . "
"; echo "The color of the sky is " . $COLOR . "
"; ?>