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;
}
$error_line='PLCAPI error: ' . $error_msg ;
if ($file) $error_line .= ' in file ' . $file;
if ($line) $error_line .= ' on line ' . $line;
- $this->errors[] = $error_line
+ $this->errors[] = $error_line;
# TODO: setup a config variable for more detailed stack traces, for API errors.
if ( TRUE ){
error_log($error_line);