how to comment out code php code example

Example 1: 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 2: comment in php

Be careful when commenting out regular expressions.

E.g. the following causes a parser error.

I do prefer using # as regexp delimiter anyway so it won't hurt me ;-)

<?php 

/*

 $f->setPattern('/^\d.*/');

*/

?>

Tags:

Php Example