Debugging PHP scripts
It will display all GET and POST variables and all the properties on a currently defined object.The code
(copy this in debug.php)
function DebugClass($class)
{
$class_vars = get_object_vars($class);
echo "<b><u>Class contents</b></u><br<br>";
foreach ($class_vars as $key => $value)
echo "<b>Property Name: </b>".$key." <b>Property Value: </b>".$value."<br>";
}
//this displays all get and post variables
function DebugIncoming()
{
echo "<b><u>GET and POST contents</b></u><br><br>";
echo "<b><font color=\"red\">GET contents</b></font><br><br>";
foreach ($_GET as $key=> $value)
echo "<b>Variable Name: </b>".$key." <b>>Variable Value: </b>".$value."<br>";
echo “<br><br>";
echo “<b><font color=\"red\">POST contents</b></font><br><br>";
foreach ($_POST as $key=> $value)
echo "<b>Variable Name: </b>".$key." <b>Variable Value: </b>".$value."<br>";
echo "<br><br>";
}//display all current POST and GET values
DebugIncoming();
Usage
Include the above file from a script you would like to debug. Also, to print out all of the currently defined properties of a class instance, use the following function:
DebugClass($objectInstance);
