1. xdebug 分析php代码:
trace代码:在php配置
xdebug.trace_format = 0
xdebug.auto_trace = Off
xdebug.trace_output_dir = /www/web/develop/erp/var/xdebug
xdebug.trace_output_name = trace.%c.%p
将auto_trace关闭,然后在php代码中进行跟踪
xdebug_start_trace();
do something....
xdebug_stop_trace();
生成的trace文件将保存到 /www/web/develop/erp/var/xdebug中
2.代码时间跟踪: xdebug_time_index()
<?php
echo xdebug_time_index(), "\n";
for ($i = 0; $i < 250000; $i++)
{
// do nothing
}
echo xdebug_time_index(), "\n";
?>
3头消息
xdebug_get_headers()
<?php
header( "X-Test", "Testing" );
setcookie( "TestCookie", "test-value" );
var_dump( xdebug_get_headers() );
?>
4 xdebug_call_class() 获取文件名,行号,函数名
<?php
function fix_string($a)
{
echo "Called @ ".
xdebug_call_file().
":".
xdebug_call_line().
" from ".
xdebug_call_function();
}
$ret = fix_string(array('Derick'));
?>
输出:
Called @ /var/www/xdebug_caller.php:12 from {main}