我有下面的代碼來回溯錯誤....但其Array對PHP
$traces = debug_backtrace();
foreach ($traces as $k => $v)
{
if ($v['function'] == 'include'
|| $v['function'] == 'include_once'
|| $v['function'] == 'require_once'
|| $v['function'] == 'require')
{
$args = '';
if (isset($v['args']) && is_array($v['args']))
{
$size = count($v['args']);
foreach ($v['args'] as $key => $arg)
{
$args .= $v['args'][$key];
if($key < $size)
{
$args .= ', ';
}
}
}
$traces .= '#' . $k . ' '
. $v['function']
. '('.$args.') called at ['
. $v['file'].':'.$v['line'].']';
}
else
{
$function = (array_key_exists('function',$v)) ?
$v['function'].'() ' : 'function_name';
$file = (array_key_exists('file',$v)) ?
$v['file'] : 'file_name';
$line = (array_key_exists('line',$v)) ?
$v['line'] : 'line';
$traces .= "#{$k} $function called at {$file}:{$line}\n";//This line giving me notice...
}
}
我得到通知的陣列字符串轉換這裏:
$traces .= "#$k $function called at $file:$line\n";
我其實想把這個數組轉換成字符串。有沒有任何方法或功能可以在不給我任何通知的情況下進行轉換...
如何更正此問題?
「$ function」,「$ file」或「$ line」都是一個數組... – Squazic