如何在MAMP中调试PHP? [英] How to debug PHP in the MAMP?
问题描述
我正在Windows上使用MAMP为WordPress网站启动Web服务器.我想调试一些PHP代码(至少将变量值写入日志/浏览器控制台/其他任何地方).我试图在PHP源代码中写这个:
I'm using MAMP on Windows to start a web server for my WordPress website. I want to debug some PHP code (at least write variable values to log/browser console/anywhere else). I've tried to write in PHP source this:
debug_to_console($args);
var_dump($args);
error_log(print_r($args,true));
并在MAMP/logs/phperror.log中查找结果.但是它什么也没写.
And looked for the result in MAMP/logs/phperror.log. But it doesn't write anything.
在这种情况下如何调试PHP代码?
How to debug PHP code in this case?
推荐答案
如果要调试WordPress,只需打开调试模式.将其添加到您的wp-config
文件中,而不是将其添加到define( 'WP_DEBUG', false );
If you want to debug WordPress, just turn on debug mode. Add this into your wp-config
file instead of this one define( 'WP_DEBUG', false );
添加此代码:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
下一步就是使用这一步:
Next step is just using this one:
error_log(print_r($args,true));
您在{your-local-website-path}/wp-content/debug.log
文件中看到的$args
这篇关于如何在MAMP中调试PHP?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!