找到了一个调试PHP源代码的好同志: PHP DEBUG TOOLS,其项目地址: http://freshmeat.net/projects/php-debug-tools/文件下载地址: http://freshmeat.net/urls/.目前,c 758 AE 3 fecce 5763 e 7546 b 958d 36 e 082是1.03版本。我这里的环境是windowxp,Apache 2.2,php5.2 Zend optimizer,后面会用PHP DEBUG TOOLS的帮助文档来解释。有些照片是从文档中拍摄的。1.安装安装前准备环境:必须首先安装X-Debug。至于如何安装X-Debug,请看http://www.xdebug.org/docs/install. 1。从http://www.xdebug.org/download.php. 2下载适合你的X-DEBUG版本。将DLL文件解压到PHP安装目录下的ext目录。比如c :/PHP/ext/PHP _ xdebug-2 . 0 . 4-5 . 2 . 8-nts . dll 3 .修改php.ini文件,增加下一段:这甚至是一个不正常的分割线。你看不到我Zend _ extension=' c :/PHP/ext/PHP _ xdebug-2 . 0 . 4-5 . 2 . 8-nts . dll ' xdebug . collect _ includes=Off xdebug . default _ enable=Off xdebug . dump _ globals=Off xdebug . dump _ once=Off xdebug . extensed _ info=Off-偶数是不正常的分界线。你看不见我。注意:这个例子是针对非线程安全版本的。对于线程安全版本,请将“Zend _ extension”更改为“Zend _ extension”。_ts '安装后,将PHP DEBUG TOOLS压缩包中的所有文件解压到网站发布目录。(假设发布目录是c:www,在其中创建一个新的调试目录,并抛出其中的所有文件。)在浏览器中输入:3358 localhost/debug/test1-debug . PHP,看到下图安装成功。。
2.调试文章1。调试错误,如下面的代码:复制代码如下。php要求。/lib/debug . PHP ';功能测试($a,$ b){ echo $ ASD;}测试(10,‘ABC’);
2.使用Debug()调试复制的代码,如下面的代码:php要求。/lib/debug . PHP ';函数test($ args){ test _ nested($ args);} function test _ nested($ args){ debug($ args);//or : debug(get _ defined _ vars());//or : debug();} test(数组(' id'=123,' str '=' test '));
3.使用dump()或dump_tofile()进行调试,例如下面的代码:按如下方式复制代码。php include_once '。/lib/dump . PHP ';function test5() { include '。/test data/test 0 . PHP ';$test=array('int'=1,' float'=2.0,' float 2 '=2.1);dump($test,$ _ SERVER);} function test1(){ test2();} function test2(){ test3();} function test3(){ test4();} function test4(){ test5();} test1();
至于dump_tofile(),一般在以下情况下使用: A。当你不想停止程序运行时,b .不是你不想显示模式数据。相反,你不能。例如,当您处于AJAX请求状态时,您仍然需要在许多地方进行调整。请参考调试目录下的test7-dump_tofile.php Note :当我运行dump()或dump_tofile()时,我发现PHP DEBUG TOOL文档无法出现。
这可以通过修改debug/lib/debug.php的代码来纠正(因为dump_tofile()已经被调用到dump(),我们只需要修改第149行的一个echo $ pre将其更改为://由Benben编辑-启动echo '脚本类型=' text/JavaScript ';echo ' document . write(';echo $ pre回声');';echo '/script ';///由笨笨编辑- end修订图: 。
4.要跟踪代码并检查系统性能,您可以浏览目录中的test3-trace.php,然后单击右下角的控制台。有关详细信息,请参考文档。(文档在压缩包的文档目录中。)三、如何与项目结合?首先把php调试工具的解压文件放在项目目录下,建立一个名为debug的目录!3360)事实上,我们只需要几个文件。比如路径为: c 360 www project name debug后,我们可以通过两种方式调试第一种。我们可以添加这样一个句子,如: include _ once('。/lib/debug.php)到项目源代码。例如,下面的: c 3360 www project name hellodebug index.php按如下方式复制代码。php include_once('。/debug/lib/debug . PHP ');$幽幽='helloworld,debug ing ';debug($ arrb);什么事?你不想每页都写这句话?看第二种方法,这里也有两种方法。1.修改php.ini并添加以下内容(将其修改到您自己的目录中): Auto _ prepend _ file=' c : www project name debug Auto _ prepend . PHP ' Auto _ append _ file=' c : www project name debug Auto _ append . PHP ' 2。修改。htaccess文件(注3360我以前从未尝试过这种方法。呵呵)PHP _ value Auto _ prepend _ file ' c : www project name debug Auto _ prepend . PHP ' PHP _ value Auto _ append _ file ' c : www project name debug Auto _ append . PHP '这样可以方便整个项目的调试。如果是AJAX开发,还是有需要的,详情请参考文档。(因为还不需要,暂时跳开了,所以不拍砖了,呵呵。).