Codeigniter 显示空白页而不是错误消息 [英] Codeigniter displays a blank page instead of error messages
问题描述
我正在使用 Codeigniter,但我得到的不是错误消息,而是一个空白页面.有什么办法可以显示 PHP 错误消息吗?没有反馈就很难调试.
I'm using Codeigniter, and instead of error messages I'm just getting a blank page. Is there any way to show PHP error messages instead? It's very hard to debug when I get no feedback.
我的环境是 Ubuntu 和 Apache.
My environment is Ubuntu with Apache.
推荐答案
由于目前为止所有解决方案似乎都不适合您,请尝试以下解决方案:
Since none of the solutions seem to be working for you so far, try this one:
ini_set('display_errors', 1);
http://www.php.net/手册/en/errorfunc.configuration.php#ini.display-errors
这明确告诉 PHP 显示错误.某些环境可以默认禁用此功能.
This explicitly tells PHP to display the errors. Some environments can have this disabled by default.
这是我在 index.php
中的环境设置:
This is what my environment settings look like in index.php
:
/*
*---------------------------------------------------------------
* APPLICATION ENVIRONMENT
*---------------------------------------------------------------
*/
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*/
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
// Report all errors
error_reporting(E_ALL);
// Display errors in output
ini_set('display_errors', 1);
break;
case 'testing':
case 'production':
// Report all errors except E_NOTICE
// This is the default value set in php.ini
error_reporting(E_ALL ^ E_NOTICE);
// Don't display errors (they can still be logged)
ini_set('display_errors', 0);
break;
default:
exit('The application environment is not set correctly.');
}
}
这篇关于Codeigniter 显示空白页而不是错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!