PHP和WordPress:调试

Ext*_*kun 9 php debugging wordpress wordpress-plugin

我正在为WordPress编写一些插件和主题,我觉得很难调试,因为在页面加载时,$ _GET,$ _POST和$ _REQUEST都是空的.即使设置了错误报告,每当出现致命错误时,我都不会收到空白页以外的错误消息.反正为WordPress启用'调试模式'吗?

谢谢!

mar*_*dge 11

梨调试Wordpress插件:http://wordpress.org/extend/plugins/wp-pear-debug/

2015年4月4日更新:上述插件在几年内未更新.您还可以使用内置的WordPress PHP调试功能wp-config.php,即:

  // Enable WP_DEBUG mode
define('WP_DEBUG', true);

// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', true);

// Disable display of errors and warnings 
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors',0);

// Use dev versions of core JS and CSS files (only needed if you are modifying these core files)
define('SCRIPT_DEBUG', true);
Run Code Online (Sandbox Code Playgroud)

有关完整的文档,请参阅https://codex.wordpress.org/Debugging_in_WordPress


Vol*_*erK 5

有一种(多于一种)方法可以为php启用"a'调试模式'".那就是安装调试器扩展,例如xdebug.
您需要一个连接到调试器并检索+显示信息的客户端.
Netbeans 6.7已经发布,其php模块支持xdebug.它已成为PHP开发的一个很好的IDE.