commenting out php code example
Example 1: php comment
// This is a single-line comment
# This is also a single-line comment
/*
This is a multiple-lines comment block
that spans over multiple
lines
*/
Example 2: comment in php
<?php
// Author : https://www.codedweb.org/
// This is a single-line comment
# This is also a single-line comment in unix and linux
/*
This is a Multi-lines comment block
by this way you can add muliple lines on it.
lines
*/
// You can also use comments to leave out parts of a code line
$var = 2 /* + 12 */ + 2;
echo $var;
?>
Example 3: comment in php
It is worth mentioning that, HTML comments have no meaning in PHP parser. So,
<!-- comment
<?php echo some_function(); ?>
-->
WILL execute some_function() and echo result inside HTML comment.
Example 4: comment in php
MSpreij (8-May-2005) says /* .. */ overrides //
Anonymous (26-Jan-2006) says // overrides /* .. */
Actually, both are correct. Once a comment is opened, *everything* is ignored until the end of the comment (or the end of the php block) is reached.
Thus, if a comment is opened with:
// then /* and */ are "overridden" until after end-of-line
/* then // is "overridden" until after */