note 102609 modified in function.debug-print-backtrace by danbrown
| From: | danbrown@php.net | Date: | Thu, 24 Feb 2011 15:06:28 +0000 |
| Subject: | note 102609 modified in function.debug-print-backtrace by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177288@lists.php.net to get a copy of this message | ||
Most methods of getting the backtrace and printing are susceptible to a certain runtime flaw.
If the user is able to produce 100+ errors this will throw an error which in turn will throw 100+
errors on each nest of get_args() creating an infinite loop and eventually downing your server.
If you are looking for a simple backtrace that (so far) will not fall to this error then use this:
<?php
foreach(debug_backtrace() as $k=>$v){
if($v['function'] == "include" || $v['function'] ==
"include_once" || $v['function'] == "require_once" ||
$v['function'] == "require"){
$backtracel .= "#".$k."
".$v['function']."(".$v['args'][0].") called at
[".$v['file'].":".$v['line']."]<br />";
}else{
$backtracel .= "#".$k." ".$v['function']."() called at
[".$v['file'].":".$v['line']."]<br />";
}
}
?>
--was--
Most methods of getting the backtrace and printing are susceptible to a certain runtime flaw.
If the user is able to produce 100+ errors this will throw an error which in turn will throw 100+
errors on each nest of get_args() creating an infinite loop and eventually downing your server.
If you are looking for a simple backtrace that (so far) will not fall to this error then use this:
foreach(debug_backtrace() as $k=>$v){
if($v['function'] == "include" || $v['function'] ==
"include_once" || $v['function'] == "require_once" ||
$v['function'] == "require"){
$backtracel .= "#".$k."
".$v['function']."(".$v['args'][0].") called at
[".$v['file'].":".$v['line']."]<br />";
}else{
$backtracel .= "#".$k." ".$v['function']."() called at
[".$v['file'].":".$v['line']."]<br />";
}
}
http://php.net/manual/en/function.debug-print-backtrace.php