Heim  >  Artikel  >  Backend-Entwicklung  >  使用Xdebug调试和优化PHP程序之[1]_PHP教程

使用Xdebug调试和优化PHP程序之[1]_PHP教程

WBOY
WBOYOriginal
2016-07-21 15:54:57780Durchsuche

作者:Haohappy     
MSN: haohappy at msn.com
Blog: http://blog.csdn.net/haohappy2004
2006-07-04
 
为什么需要Debugger?
很多PHP程序员调试使用echo、print_r()、var_dump()、printf()等,其实对于有较丰富开发经验的程序员来说这些也已经足够了,他们往往可以在程序执行的过程中,通过输出特定变量的值可以判断程序执行是否正确,甚至效率高低也可以看出来(当然可能还需要使用一些时间函数)。那么我们为什么还需要一个专门的调试程序来监控我们的程序运行呢? 这个问题的答案不妨留到后面来揭晓。
 
什么是Xdebug?
Xdebug是一个开放源代码的PHP程序调试器(即一个Debug工具),可以用来跟踪,调试和分析PHP程序的运行状况。Xdebug现在的最新版本是xdebug 2.0.0beta6,支持PHP4/PHP5。
 
官方站点:www.Xdebug.org
 
如何安装Xdebug
以PHP5.1.4,Windows平台为例(其它PHP版本,其它平台请参看官网文档):
1. 登录www.xdebug.org,在首页右侧有一个Windows modules,选择其中的PHP5.1.2+,下载php_xdebug-5.1.2-2.0.0beta6.dll文件;
 
2. 将下载的php_xdebug-5.1.2-2.0.0beta6.dll放到C:\php5\ext目录,重命名为php_xdebug.dll;
3. 编辑php.ini,加入下面几行:
extension=php_xdebug.dll
[Xdebug]
xdebug.profiler_enable=on
xdebug.trace_output_dir="I:\Projects\xdebug"
xdebug.profiler_output_dir="I:\Projects\xdebug" 
 
后面的目录“I:\Projects\xdebug”为你想要放置Xdebug输出的数据文件的目录,可自由设置。
4. 重启Apache;
5. 写一个test.php,内容为,如果输出的内容中有看到xdebug,说明安装配置成功。
现在我们就可以开始使用Xdebug强大的功能了!

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/318377.htmlTechArticle作者: Haohappy MSN: haohappy at msn.com Blog: http://blog.csdn.net/haohappy2004 2006-07-04 为什么需要 Debugger? 很多PHP程序员调试使用echo、print_r()、var_dump()、...
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn