PHP和WordPress:调试 [英] PHP and WordPress: Debugging

查看:110
本文介绍了PHP和WordPress:调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为WordPress编写一些插件和主题,我发现很难调试,因为在页面加载的时候,不知何故,$ _GET,$ _POST和$ _REQUEST都是空的。即使设置了错误报告,除非出现致命错误,否则我不会收到除空白页面之外的错误消息。有没有为WordPress启用调试模式?



谢谢!

解决方案

Pear Debug Wordpress插件: http://wordpress.org/extend / plugins / wp-pear-debug /



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

  //启用WP_DEBUG模式
define('WP_DEBUG',true);

//启用Debug记录到/wp-content/debug.log文件
define('WP_DEBUG_LOG',true);

//禁止显示错误和警告
define('WP_DEBUG_DISPLAY',false);
@ini_set('display_errors',0);

//使用核心JS和CSS文件的开发版本(仅在您修改这些核心文件时才需要)
define('SCRIPT_DEBUG',true);

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


I am writing some plugins and themes for WordPress, and I finding it hard to debug because somehow by the time the page has loaded, $_GET, $_POST and $_REQUEST are all empty. Even with error reporting set on, I am not getting error messages either other than a blank page whenever there is a fatal error. Is there anyway to enable a 'debug mode' for WordPress?

Thanks!

解决方案

Pear Debug Wordpress plugin: http://wordpress.org/extend/plugins/wp-pear-debug/

Update 4/08/2015: The above plugin hasn't been updated in a few years. You can also use the built-in WordPress PHP debugging functions in wp-config.php , i.e.:

  // 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);

See https://codex.wordpress.org/Debugging_in_WordPress for the complete docs

这篇关于PHP和WordPress:调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆