开发者

How to more effectively debug PHP code in the vein JavaScript with Firebug or XCode?

开发者 https://www.devze.com 2022-12-26 01:46 出处:网络
I\'m kind of a newbie with PHP so please bear with me. I would like to know if there was an effective way of debugging PHP code so that I don\'t have to have debugging messages display on the browser.

I'm kind of a newbie with PHP so please bear with me. I would like to know if there was an effective way of debugging PHP code so that I don't have to have debugging messages display on the browser.

For example, I find var_dump and print_r functions to be excellent for debugging variables, function calls and arrays respectively. The problem is I have been asked to debug code on a live site (no dev site, I know it is a horrible practice but this is not my project from the start.) So I would like to know what core function or php library or whatever else it is that I 开发者_C百科could use to log debugging calls in to log that I can check so I don't have to send debugging calls to the browser on a live site?

I like the way you can use the console.log function in JavaScript code and check it in Firebug or the Webkit Console and I also like like the console window in Xcode and I was wondering if there was some similar tool for PHP debugging. Any extra info and pearls of wisdom would be greatly appreciated.

Thanks,

racl101.


To debug the live site you need to have Zend Debugger extension installed on its server. Its configuration has to allow you to connect to the debugger from your IP address. See this guide from Zend.

Next you will have to use a supported debugger client. Have a look at Zend Studio for Eclipse which is nice, or you can use Eclipse PDT with Zend Debugger plugin.

Once you are setup (client and server) you will be able to set breakpoints in your code and see variables / step through code while running, etc.

Alternative to Zend Debugger is xDebug.


If you just want to write to a log file, there's the function error_log. It'll write to your webserver's error log file (which will vary in location from system to system depending on how the webserver is setup).

0

精彩评论

暂无评论...
验证码 换一张
取 消