Posted By

xkeshav on 08/12/10


Tagged

php debug


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

xkeshav


code to debug variables


 / Published in: PHP
 

This is the PHP code to debug any variable ..

  1. /** This function is used to debug variables during page execution
  2. * @param $what , the variable which need to debug,can be array or single variable
  3. * @param $more , to know the method and line number where that variable is used
  4. * @param $die , set TRUE if want to stop the page
  5. * how to use : debug::watch($postarray,1,1);
  6. * @author keshav mohta
  7. * @date Aug 12, 2010
  8. */
  9. class debug()
  10. {
  11. static function watch($what,$more=FALSE,$die=FALSE)
  12. {
  13.  
  14. if($more && isset($d[1]))
  15. {
  16. echo "<br/>METHOD:".$d[1]['class']."::".$d[1]['function'];
  17. echo "<br/>LINE:".$d[0]['line'];
  18. }
  19. echo "<br/>";
  20. if( is_array($d[0]['args'][0]) || is_object($d[0]['args'][0]) )
  21. {
  22. echo "DATA:<pre>";
  23. print_r($d[0]['args'][0]);
  24. echo "</pre>";
  25. }
  26. else
  27. {
  28. echo "Data:".$d[0]['args'][0];
  29. }
  30.  
  31. if($die)
  32. {
  33. echo "<br/>";
  34. die('ends here');
  35. }
  36.  
  37. }
  38. }

Report this snippet  

You need to login to post a comment.