Advertisement
n0tmE

getTraceAsString implementation

Mar 10th, 2011
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.55 KB | None | 0 0
  1. public function getTraceAsString(Exception $ex) {
  2.     $str = '';
  3.     foreach($ex->getTrace() as $index => $trace) {
  4.         $str .= "#$index {$trace['file']}({$trace['line']}): {$trace['class']}->{$trace['function']}(";
  5.         $args = array();
  6.         foreach($trace['args'] as $arg) {
  7.             if (is_object($arg))
  8.                 $args[] = 'Object(' . get_class($arg) . ')';
  9.             elseif (is_array($arg))
  10.                 $args[] = 'Array';
  11.             else
  12.                 $args[] = var_export($arg, true);
  13.         }
  14.         $str .= join(', ', $args);
  15.         $str .= ")\n";
  16.     }
  17.     $index++;
  18.     $str .= "#$index {main}";
  19.  
  20.     return $str;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement