w3reference home
PHP Tutorial


Bookmark and Share

PHP comments

Comment is that part of the code that is not parsed by the parser. The main objective of the comment is to provide necessary notes to the programmer. It helps in understanding the code better. Every language has a different way of storing a comment. In PHP, the comments are stored in a manner similar to that of C++. Let's see a single line comment in a PHP script.
<?php
//echo "We are checking a comment.";
echo "We are checking a comment.";
?>
The output will be:
We are checking a comment.
Why is there only a single line in the output when we have given the echo command twice. The reason is that the first statement is a comment. Any statement written after double slash (//) will not be parsed by the parser and hence, you can put absolutely any notes there for your convenience. But now suppose, we want to add multiple lines of comment instead of a single line comment. It would be very tedious to put "//" at the beginning of each line. This problem has been simplified. Multiple line comments are handled in the following manner:
<?php
/*This is a multiple line comment.
You can as many lines as you want here.
They will not affect the PHP script.*/
echo "We just learnt multiline comment.";
?>
In the above code, we have used "/*" to mark the beginning of the comment and "*/" to mark the end of the comment. And here's the output to the above script:
We just learnt multiline comment.
Code Validator
Learn FTP
Color finder
Link Checker
Free web designs
Coming soon!
Interview Questions...
'w3reference : Learn by examples ... Advanced to beginner's tutorials ...'
Ajax: AJAX tutorial1 | Apache: Apache HTTP Server | Restarting Apache | CSS: CSS Border | CSS Syntax | CSS Selector | CSS Comment | CVS: CVS Release | CVS Login | CVS Logout | CVS Annotate | Databases: Rolap Tutorial | OLAP Tutorial | OLTP Tutorial | data warehousing | Expect: HTML: html | Linux: Dot (.) conf files | Linux Mount Point | Linux Filesystem | SSH Tutorial | Linux Commands: cal | cat | cfdisk | chroot | MySQL: MySQL Commands | PHP: PHP Basics | PHP Variables | PHP Output (echo/print) | PHP String Concat | PL/SQL: PL/SQL Data Types | PL/SQL Control Structures | PL/SQL File Extensions | PL/SQL DBMS_OUTPUT package | Python: My first Python program | Shell: Starting Bash | Bash Redirection | Bash Pipes | Bash Variables | SQL: SQL Transactions | SQL Constraints | SQL Drop | SQL Union & Union All | SVN: svn architecture | SVN Repository | SVN Import | SVN Checkout | Tech: soap | Web Designing: Web Hosting | HTML/XHTML/CSS code validator | Learn FTP | Search Engine Optimization Tips | www: XML: XML vs HTML | XML Syntax | XML Tags, Elements and Attributes | XML Namespaces |
Sitemap | Disclaim | Privacy Policy | Contact | ©2007-2009 w3reference.com All Rights Reserved.