Posted By

ikimozu on 04/27/09


Tagged

debug dump


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

lfx


var_dump wrapper


 / Published in: PHP
 

displayed filename and line number.

//normal use

d( $arg );

//some arguments

d( $arg1 , $arg2 , ... );

  1. function d($var){
  2. $args=func_get_args();
  3. if(count($args)>1){
  4. $var=$args;
  5. }
  6. var_dump($var);
  7. $dump=ob_get_contents();
  8. $trace=debug_backtrace();
  9. $file=str_replace($_SERVER['DOCUMENT_ROOT'],"",$trace[0]['file']);
  10. $line=$trace[0]['line'];
  11. echo '<pre>';
  12. echo '<b>'.$file.' (Line:'.$line.')</b>'."\n";
  13. echo str_replace('<','&lt;',str_replace('>','&gt;',$dump));
  14. echo '</pre><br>'."\n";
  15. }

Report this snippet  

You need to login to post a comment.