From: Stephen Soltesz Date: Thu, 12 May 2011 21:52:28 +0000 (-0400) Subject: Print php.log stack traces in reverse order (a more standard order) X-Git-Tag: plcapi-5.0-33~4^2 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=71242511f93381fde9bae82e32f705a3f7dd7aff;hp=ee9209667367de49fb2430251cdb741cdb8e427c;p=plcapi.git Print php.log stack traces in reverse order (a more standard order) --- diff --git a/php/plc_api.php b/php/plc_api.php index 3224601..41f65c2 100644 --- a/php/plc_api.php +++ b/php/plc_api.php @@ -61,9 +61,13 @@ class PLCAPI function backtrace_php () { $backtrace = debug_backtrace(); $msg = ""; - foreach( $backtrace as $line ) { + $len = count($backtrace); + $cnt = 1; + foreach( array_reverse($backtrace) as $line ) { $msg .= "File '". $line['file'] . "' line " . $line['line'] . "\n"; $msg .= " " . $line['function'] . "( " . $this->rec_join($line['args']) . ")\n"; + $cnt += 1; + if ( $cnt == $len ) { break; } } return $msg; }