php xdebug安装

发布时间:2021-07-16 17:07:56 阅读:1192次

 http://www.cnblogs.com/mo-beifeng/articles/2446142.html
http://www.zhuoda.org/xiezhi/102263.html
http://www.phpchina.com/archives/view-33581-1.html

 1655  cd xdebug-2.2.3/
 1656  ls
 1657  /usr/local/php5/bin/phpize 
 1658  ./configure --enable-xdebug --with-php-config=/usr/local/php5/bin/php-config
 1659  make
 1660  make install

Xdebug使调试信息更加美观 
Xdebug扩展加载后,Xdebug会对原有的某些PHP函数进行覆写, 以便好更好地进行Debug。比如var_dump()函数,我们知道通常我们需要在函数前后加上”<pre>…</pre>” 才能够让输出的变量信息比较美观、可读性好。但是加载了Xdebug后,我们不再需要这样做了,Xdebug不但自动给我们加上了<pre> 标签,还给变量加上颜色。 
例:

<?php
$arrTest=array(
       "test"=>"abc",
       "test2"=>"abc2"
);

var_dump($arrTest);
?>

Xdebug测试脚本执行时间 
测试某段脚本的执行时间,通常我们都需要用到microtime()函数来确定当前时间。例如PHP手册上的例子:

<?php
/**
* Simple function to replicate PHP 5 behaviour
*/
function microtime_float()
{
    list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}

$time_start = microtime_float();
// Sleep for a while
usleep(100);
$time_end = microtime_float();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds\n";
?>

但是microtime()返回的值是微秒数及绝对时间戳(例如“0.03520000 1153122275”),没有可读性。所以如上程序,我们需要另外写一个函数microtime_float(),来将两者相加。
Xdebug自带了一个函数xdebug_time_index()来显示时间。

PHP脚本占用的内存
有时候我们想知道程序执行到某个特定阶段时到底占用了多大内存,为此PHP提供了函数memory_get_usage()。这个函数只有当PHP编译时使用了--enable-memory-limit参数时才有效。 

Xdebug同样提供了一个函数xdebug_memory_usage()来实现这样的功能,另外xdebug还提供了一个xdebug_peak_memory_usage()函数来查看内存占用的峰值。

如有问题,可以QQ搜索群1028468525加入群聊,欢迎一起研究技术

支付宝 微信

有疑问联系站长,请联系QQ:QQ咨询
下一篇:php etags

转载请注明:php xdebug安装 出自老鄢博客 | 欢迎分享