Created
May 23, 2011 07:35
-
-
Save xkeshav/986359 to your computer and use it in GitHub Desktop.
how to debug in php files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** This function is used to debug variables during page execution | |
* @param $what , the variable which need to debug,can be array or single variable | |
* @param $more , to know the method and line number where that variable is used | |
* @param $die , set TRUE if want to stop the page | |
* how to use : debug::watch($postarray,1,1); | |
* @author keshav mohta | |
* @date Aug 12, 2010 | |
*/ | |
class debug() | |
{ | |
static function watch($what,$more=FALSE,$die=FALSE) | |
{ | |
$d = debug_backtrace(); | |
if($more && isset($d[1])) | |
{ | |
echo "<br/>METHOD:".$d[1]['class']."::".$d[1]['function']; | |
echo "<br/>LINE:".$d[0]['line']; | |
} | |
echo "<br/>"; | |
if( is_array($d[0]['args'][0]) || is_object($d[0]['args'][0]) ) | |
{ | |
echo "DATA:<pre>"; | |
print_r($d[0]['args'][0]); | |
echo "</pre>"; | |
} | |
else | |
{ | |
echo "Data:".$d[0]['args'][0]; | |
} | |
if($die) | |
{ | |
echo "<br/>"; | |
die('ends here'); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment