php comment syntax code example
Example 1: comment in php
<?php
/*
echo 'This is a test'; /* This comment will cause a problem */
*/
?>
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: php comment
<?php
// 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
*/
// You can also use comments to leave out parts of a code line
$x = 5 /* + 15 */ + 5;
echo $x;
?>
Example 4: 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 5: comment in php
<h1>This is an <?php # echo 'simple';?> example</h1>
<p>The header above will say 'This is an example'.</p>