PHP Comments

Submitted by: 
Language: 
Visitors have accessed this post 2204 times.

One of the best programming practice is using a Comment. A comment is a string code or text within PHP or any programming languages that is not visible during the execution in your web browser. And it provides the feedback to the developers or it temporarily disable the code and the most important thing is that comment serves to give some information about the code.

In PHP, there are two types of Comment. The Single line comment and the Multiple line comment.

PHP comment syntax: single line comment
The single line comment only ignores everything to the end of the line or the current block of PHP code. To make a single line comment, you can simply type “//” or “#” and all text right will be disabled by the PHP interpreter.

Example:

  1. <?php
  2. echo "This is a test sample";//this will output This is a test sample
  3. //the next two line of code will echo nothing
  4. //echo "This is a Second sample";
  5. #echo "This is third sample";
  6. ?>

Output:

This is a test sample

PHP comment syntax: Multiple line comment
The multiple line comment used to comment large block of code. The multiple line comment in PHP starts with “/*” and ends with “*/”.
Example:

  1. <?php
  2. echo "This is a test sample";//this will output This is a test sample
  3. /*the next two line of code will echo nothing
  4. echo "This is a Second sample";
  5. echo "This is third sample";
  6. */
  7. ?>

Output:
This is a test sample


Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
CAPTCHA
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.