博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
php扩展xdebug基本使用
阅读量:1983 次
发布时间:2019-04-27

本文共 2275 字,大约阅读时间需要 7 分钟。

官网: 

使用:

 

安装

 

使用

 

1.获取文件名,行号,函数名

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}
 
2.输出head信息
xdebug_get_headers()

输出:

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

 

 

3.输出执行时间

xdebug_time_index()

4.代码覆盖

xdebug_start_code_coverage();

代码

var_dump(xdebug_get_code_coverage());

看图更明显

 

5.代码跟踪

需要跟踪的代码:

class myClass{    public function a($a) {        echo $a * 2.5;    }    public function b($b) {       $this->a($b + 2);    }}xdebug_start_trace('trace');$obj=new myClass();$obj->b(6);echo "
";xdebug_stop_trace();

--------------------------------------------------------------------------

xdebug配置参考

xdebug.default_enable = Onxdebug.show_exception_trace = Onxdebug.show_local_vars = 1xdebug.max_nesting_level = 50xdebug.var_display_max_depth = 6xdebug.dump_once = Onxdebug.dump_globals = Onxdebug.dump_undefined = Onxdebug.dump.REQUEST = *xdebug.dump.SERVER = REQUEST_METHOD,REQUEST_URI,HTTP_USER_AGENTxdebug.trace_format = 0xdebug.auto_trace = Onxdebug.trace_output_dir = E:\xampp\tmp\tracesxdebug.trace_output_name = trace.%c.%pxdebug.collect_params = 4xdebug.collect_includes = Onxdebug.collect_return = Onxdebug.show_mem_delta = On

设置xdebug.auto_trace = Off可在代码中添加xdebug_start_trace();xdebug_stop_trace();语句生成追踪文件。

使用xdebug_start_trace跟踪代码执行

xdebug_start_trace('trace');$a->myCaller($b);xdebug_stop_trace();TRACE START [16:53:57]0.0010      57964    -> MyClass->myCaller() /code/xdebug.php:210.0011      58104     -> MyOther->myCallee() /code/xdebug.php:40.0011      58104      -> xdebug_call_class() /code/xdebug.php:100.0011      58128      -> printf() /code/xdebug.php:100.0014      58196      -> xdebug_call_function() /code/xdebug.php:110.0015      58196      -> printf() /code/xdebug.php:110.0016      58196      -> xdebug_call_file() /code/xdebug.php:120.0016      58244      -> printf() /code/xdebug.php:120.0017      58244      -> xdebug_call_line() /code/xdebug.php:130.0017      58244      -> printf() /code/xdebug.php:130.0018      58244   -> xdebug_stop_trace() /code/xdebug.php:220.0019      58244TRACE END [16:53:57]

 

转载地址:http://pwzvf.baihongyu.com/

你可能感兴趣的文章
freeswitch添加坐席/usr/local/freeswitch/conf/directory/default
查看>>
JavaScript原生开关灯效果
查看>>
企业邮箱如何申请注册,邮箱申请如何免费注册?
查看>>
微信企业邮箱,手机邮箱格式地址怎么写?
查看>>
公司如何申请企业邮箱,公司邮箱怎么申请,公司企业邮箱哪个好?
查看>>
电子邮箱账号怎么申请,怎样申请邮箱账号呢
查看>>
邮箱怎么发邮件,邮件发信量多少,职场新人怎么发汇报邮件呢?
查看>>
maven 多层次pom 新引入包,编译成功,还是没有将包引入到本地
查看>>
leetCode2 两数相加
查看>>
【工具使用】使用pip与conda安装、更新与卸载Pytorch和torchvision
查看>>
【深度学习笔记】batchsize, time step(iteration), epoch 区别与联系
查看>>
【解决错误】ModuleNotFoundError No module named matplotlib
查看>>
【工具使用】Google免费云环境Colaboratory使用
查看>>
【深度学习笔记】卷积层,全连接层,池化层的相关输出参数计算
查看>>
【NLP学习笔记】文本分类概述
查看>>
【深度学习笔记】文本分类
查看>>
【转载】炼丹实验室:深度学习网络调参技巧
查看>>
【论文阅读笔记】Graph Convolutional Networks for Text Classification
查看>>
【论文阅读笔记】文本分类论文汇总
查看>>
【论文阅读笔记】Convolutional Neural Networks for Sentence Classification
查看>>