Comment in PHP

A comment is the portion of a program that exists only for the human reader and stripped out before displaying the programs result.

There are two commenting formats in PHP:

  • Single-line comments
  • Multi-lines comments

Single-line comments: They are generally used for short explanations or notes relevant to the local code. Here are the examples of single line comments.

    
        <?
            # This is a single line comment
            // This is a comment too. Each style comments only
            echo "hello world";
        ?>
    

Multi-lines Comments: They are generally used to provide pseudocode algorithms and more detailed explanations when necessary. The multiline style of commenting is the same as in C. Here are the example of multi lines comments.

    
        <?
            /* This is a single line comment
             This is a comment too. Each style comments only */
            echo "hello world";
        ?>
    

PHP is whitespace insensitive

Whitespace is the stuff you type that is typically invisible on the screen, including spaces, tabs, and carriage returns (end-of-line characters).

PHP whitespace insensitive means that it almost never matters how many whitespace characters you have in a row.one whitespace character is the same as many such characters.


PHP is case sensitive

    
        <html>
        <body>
            <?
                $capital = 67;
                print("Variable capital is $capital<br>");
                print("Variable CaPiTaL is $CaPiTaL<br>");
            ?>
        </body>
        </html>

    

Statements are expressions terminated by semicolons

A statement in PHP is any expression that is followed by a semicolon (;).Any sequence of valid PHP statements that is enclosed by the PHP tags is a valid PHP program.