|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-08-17 18:59 UTC] sniper@php.net
[2005-08-22 16:23 UTC] flummi at everymail dot net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 05:00:01 2025 UTC |
Description: ------------ When calling debug_backtrace from an own error handler, it provides a different output than when calling it directly. As you can see in the code, I have two calls to debug_backtrace, one from my error handler, the other from a function. As I raise an error shortly after calling debug_backtrace the first time, I would expect to have the same first few entries in the debug_backtrace array. I.e. the last entry shows an error on line 18, where the function 'a_test' is called with arg 'another friend'. In real this function is called with the arg 'friend' (arg 'another friend' is used in the next function call. I hope I could explain the bug good enough as my natural language is german. :-) Reproduce code: --------------- <pre> <?php function HandleError($n, $m, $f, $l){ print_r(debug_backtrace()); } set_error_handler('HandleError'); function a_test($str) { echo "\nHi: $str"; b_test("another friend"); } function b_test($str2) { echo "\nHi $str2"; print_r(debug_backtrace()); echo "now raise an error..".(2/0); } a_test('friend'); ?> </pre> Expected result: ---------------- Hi: friend Hi another friendArray ( [0] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 10 [function] => b_test [args] => Array ( [0] => another friend ) ) [1] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 18 [function] => a_test [args] => Array ( [0] => friend ) ) ) Array ( [0] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 16 [function] => HandleError ) [1] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 16 [function] => b_test ) [2] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 10 [function] => b_test [args] => Array ( [str2] => another friend ) ) [3] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 18 [function] => a_test [args] => Array ( [0] => friend ) ) ) Actual result: -------------- Hi: friend Hi another friendArray ( [0] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 10 [function] => b_test [args] => Array ( [0] => another friend ) ) [1] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 18 [function] => a_test [args] => Array ( [0] => friend ) ) ) Array ( [0] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 16 [function] => HandleError ) [1] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 16 [function] => b_test ) [2] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 10 [function] => b_test [args] => Array ( [0] => 2 [1] => Division by zero [2] => /var/www/html/xiview/test/testerror2.php [3] => 16 [4] => Array ( [str2] => another friend ) ) ) [3] => Array ( [file] => /var/www/html/xiview/test/testerror2.php [line] => 18 [function] => a_test [args] => Array ( [0] => another friend ) ) )