php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #18161 backtrace and zend engine 2 (alpha 2)
Submitted: 2002-07-04 07:12 UTC Modified: 2002-07-17 03:51 UTC
From: ol at globalis-ms dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4CVS-2002-07-04 OS: linux - i386
Private report: No CVE-ID: None
 [2002-07-04 07:12 UTC] ol at globalis-ms dot com
Hi,

I've tried to test the backtrace function in zend engine 2 alpha 2. And i'm not able to get any usable output.

Is it a known bug (no KNOWN_BUG file, in archive), or it's just not the right way to use it ? 


Example 1 (from the Change log doc)
Output -> <empty>
<?php
$backtrace = debug_backtrace();

foreach ($backtrace as $step) {
   $class = isset($step['class']) ? $step['class'] . '::' : '';

   printf(
        "%s [%s:%s]\n",
        $step['function'],
        $step['file'],
        $step['line']
        );
   }
?>


Example 2 (from my own)
Output -> <empty Array>

<?php
function foo(){
echo "function --> foo\n";
}

$backtrace = debug_backtrace();
foo();
print_r($backtrace);
?>

Thanks,

My conf:
./configure --without-apache --without-pear
on a linuxbox - slackware 8.1 / i386

--
Ol

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-07-16 15:35 UTC] optikSmoke at subdimension dot com
Ummm,  I believe the problem you are having is that you 
are calling debug_backtrace() from the top level of the 
script. I have been using debug_backtrace() quite 
effectively to develop a printStackTrace() method for 
exceptions in my scripts, and in my testing I found that 
it will nnot output anything unless the call is made from 
within a function/method. eg: 
<? 
function foo() { 
	debug_backtrace(); 
	print_r(debug_backtrace()); 
} 
foo(); 
?> 
Try that. I could be wrong, but I don't think 
debug_backtrace() was meant to be used from the top level 
of scripts.
 [2002-07-17 03:50 UTC] ol at globalis-ms dot com
Hi,

Ok, you 're true :)
I did not really understood it at first time.
I believed is behaviour was a bit like ticks with one
call on top and no more.

In fact i need to call debug_backtrace as many time that 
i want/need to trace a single function or method...

Thanks for help :)

For example this script work fine :

<?php

function display_backtrace(){
    $debug = debug_backtrace();
    array_shift($debug); /* remove call to display_backtrace himself */
    print_r($debug); // display call stack
}

function foo() {
    display_backtrace(); // need to debug
}

function call_foo(){
    foo();
}

call_foo();
?>

--
Ol
 [2002-07-17 03:51 UTC] derick@php.net
Not a bug -> bogus
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 07:00:01 2026 UTC