xdebug调试php程序

相关设置

xdebug.default_enable=1

默认是1,当错误出现时,堆栈跟踪会激活。可以在代码中通过xdebug_disable()来关闭它。

xdebug.force_display_errors=0

默认是0,如果设置为1,错误总是会被展示,不管PHP的display_errors是怎么设置的。

xdebug.force_error_reporting=0

默认是0,就像error_reporting。允许你强制显示特定级别的错误,不管程序中的ini_set()如何设置。它只能通过php.ini修改。

xdebug.halt_level=0

xdebug.max_nesting_level=100

xdebug.scream=0

如果设置为1,会屏蔽@操作符,以至于notices,warnings和errors不在隐藏。

相关函数

string xdebug_call_class()

返回调用的class

<?php
    function fix_string($a)
    {
        echo "Called @ ".
            xdebug_call_file().
            ":".
            xdebug_call_line().
            " from ".
            xdebug_call_function();
    }

    $ret = fix_string(array('Derick'));
?>

 

返回:

Called @ /home/httpd/html/test/xdebug_caller.php:12 from {main}

string xdebug_call_file()

 

返回调用的文件

string xdebug_call_function()

 

返回调用的函数/方法

int xdebug_call_line()

 

返回行号

void xdebug_disable()

禁用堆栈跟踪
void xdebug_enable()
开启堆栈跟踪
void xdebug_get_collected_errors( [int clean] )
 

返回所有收集到的错误信息

array xdebug_get_headers()

 

返回PHP的header()函数设置的headers

<?php
header( "X-Test", "Testing" );
setcookie( "TestCookie", "test-value" );
var_dump( xdebug_get_headers() );
?>

 

返回:

array(2) {
  [0]=>
  string(6) "X-Test"
  [1]=>
  string(33) "Set-Cookie: TestCookie=test-value"
}

bool xdebug_is_enabled()

 

返回堆栈跟踪是否开启

int xdebug_memory_usage()

 

返回当前占用内存

int xdebug_peak_memory_usage()

返回占用内存的峰值

void xdebug_start_error_collection()

 

开始收集所有的notices,warnings和errors并阻止它们被显示

void xdebug_stop_error_collection()

停止收集所有的notices,warnings和errors。

float xdebug_time_index()

 

返回当前时间索引

<?php
echo xdebug_time_index(), "\n";
for ($i = 0; $i < 250000; $i++)
{
    // do nothing
}
echo xdebug_time_index(), "\n";
?>

 

返回

0.00038003921508789
0.76580691337585

 

posted @ 2014-12-30 14:25  yikai.shao  阅读(412)  评论(1编辑  收藏  举报