note 99690 added to exception.gettrace
| From: | sskaje at gmail dot com | Date: | Tue, 31 Aug 2010 04:57:54 +0000 |
| Subject: | note 99690 added to exception.gettrace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-172187@lists.php.net to get a copy of this message | ||
Exceptions thown in a function/method been called via 'call_user_func' or
'call_user_func_array', have key 'file' and 'line' disappeared in
their first element (array[0]) from Exception::getTrace().
<?php
function test() {
debug_print_backtrace();
throw new Exception('1');
}
try {
test();
} catch (Exception $e) {
var_dump($e->getTrace());
}
function callback() {
call_user_func('test');
}
try {
callback();
} catch (Exception $e) {
var_dump($e->getTrace());
}
?>
G:\wwwroot\Test\Exception>php trace_func.php
#0 test() called at [G:\wwwroot\Test\Exception\trace_func.php:8]
array(1) {
[0]=>
array(4) {
["file"]=>
string(40) "G:\wwwroot\Test\Exception\trace_func.php"
["line"]=>
int(8)
["function"]=>
string(4) "test"
["args"]=>
array(0) {
}
}
}
#0 test()
#1 call_user_func(test) called at [G:\wwwroot\Test\Exception\trace_func.php:14]
#2 callback() called at [G:\wwwroot\Test\Exception\trace_func.php:18]
array(3) {
[0]=>
array(2) {
["function"]=>
string(4) "test"
["args"]=>
array(0) {
}
}
[1]=>
array(4) {
["file"]=>
string(40) "G:\wwwroot\Test\Exception\trace_func.php"
["line"]=>
int(14)
["function"]=>
string(14) "call_user_func"
["args"]=>
array(1) {
[0]=>
string(4) "test"
}
}
[2]=>
array(4) {
["file"]=>
string(40) "G:\wwwroot\Test\Exception\trace_func.php"
["line"]=>
int(18)
["function"]=>
string(8) "callback"
["args"]=>
array(0) {
}
}
}
Similar result given by debug_print_backtrace(), is this a bug or an unexpected feature ? XD
----
Server IP: 69.147.83.197
Probable Submitter: 218.240.150.33
----
Manual Page -- http://www.php.net/manual/en/exception.gettrace.php
Edit -- https://master.php.net/note/edit/99690
Del: integrated -- https://master.php.net/note/delete/99690/integrated
Del: useless -- https://master.php.net/note/delete/99690/useless
Del: bad code -- https://master.php.net/note/delete/99690/bad+code
Del: spam -- https://master.php.net/note/delete/99690/spam
Del: non-english -- https://master.php.net/note/delete/99690/non-english
Del: in docs -- https://master.php.net/note/delete/99690/in+docs
Del: other reasons-- https://master.php.net/note/delete/99690
Reject -- https://master.php.net/note/reject/99690
Search -- https://master.php.net/manage/user-notes.php