PHP Comments

the php comments can be used to make the code more readable.

the php comments code is not executed by interpreter.


the comment is simply text that is ignored by the php engine.

the php support two types of comment

  • single-line comment        // comment -code
  • multiline-line comment     /* ....comment code */

PHP single line comments

single-line comments begins with a double foreslash (//).

if single-line comments are used, the php interpreter ignores any text between the comment marker(//) and the end of the line.

example:

 <?php

    $count =10 ;  //holds number of items the user wishes to purchase
                     
    $name   ="sandeep kumar nehra" ;  // the declare the string type variable
                     
             echo "the count value = $count";
       
             echo "the name  value = $name";  
        
  ?>                         

PHP Multi-line comments

multi-line comments start with /*    and ends with    */ .

if multi-line comments are used, the php interpreter ignores any text between the beginning (/*) and end markers(*/).

example:

 <?php
 
 /* 
the code below will declare a number type count  and string type name variable.
   
the echo methos write values on the output stream.
        
use this php code  */      
  
   $count =10 ;  //holds number of items the user wishes to purchase
                     
   $name   ="sandeep kumar nehra" ;  //the declare the string type variable
                        
  ?>                         

note:the multiline comments cannot be nested.

the following will result in an error

          /* the code   /*  this is nested code */    text */

note:for security and performance sake, you may wish to remove comments from your script before it is delivered to end users on the web.

hash symbol (#) can used to creat comment in php code look like:

         # this is php comment

PHP case sensitivity

in php all user-defined classes, function, are case-insensitive.

in php all variables are case-sensitive.

   <body>
      
        <?php
        
                        echo "hello php <br/>";
                        
                        echo "hello php <br/>";  //all  echo statements work same;
                          
                        echo "hello php <br/>" // php functions are case-insensitive
                          
       ?>
      
  </body>
-->