A handy way of commenting for debugging

First off, this is not rocket science, just something I noticed that I hadn't noticed in the thousands of lines of PHP code I've written. :) Sometimes in my code I like to print() some things just to see what certain variables look like for debugging. Here is an example.

<?php
/*
$vals = array("this","is","an","array");
foreach($vals as $val){
  print $val . "\n";
}
*/

?>

Here is a quick example that uses block commenting (/* and */) to enclose the whole thing.

I used to go and delete or add those, but I thought of a quick way to enable or disable them without erasing them to disable them. Just comment them out as below.

<?php
#/*
$vals = array("this","is","an","array");
foreach($vals as $val){
  print $val . "\n";
}
#*/
?>

Page Comments (Click to edit)






[Click to add or edit comments])

Please prepend comments below including a date

Design by N.Design Studio, adapted by solidGone.org (version 1.0.0)
Have a nice day.