30 September 2013

How to Comment your code in PHP?

  • PHP supports 'C', 'C++' and Unix shell-style (Perl style) comments. 
  • You may use any style based on your requirements. 
  • Single-Line code comments use C++ Syntax 
  • Multiple-Line code comments use C Syntax 
  • Unix Shell Syntax (Perl Style) is also used for single line comments 
  • Example: Single-Line C++ Syntax
1
2
3
4
5
6
7
 <?php

        // Title: My first PHP code

          echo "This is a PHP program.";

    ?>
  • Example: Unix Shell Syntax
1
2
3
4
5
6
7
 <?php

       # Title: My first PHP code

          echo "This is a PHP program.";

    ?>
  • Example: Multiple-Line C Syntax
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<?php

    /*

    Title: Test Code

    Author: shafiq

    Author URL: http://shafiq2410.wordpress.com

    Email: shafiq2410@gmail.com

    */

    echo "This is a PHP program.";

    ?>
PHP Cookbook: Solutions & Examples for PHP Programmers

No comments:

Post a Comment

Featured Post

How to Write PHP code and HTML code within a same file

A PHP file can have both PHP code and HTML code together. Any HTML code written outside of PHP <?php //php code here… ?> Code is ig...

Popular Posts