使用 .htaccess 处理错误的另一种方法是创建一个可配置的 php 文件,该文件可以像其他框架一样在开发、生产和测试阶段进行设置。
* You can load different configurations depending on your
* current environment. Setting the environment also influences
* things like logging and error reporting.
*
* This can be set to anything, but default usage is:
*
* development
* testing
* production
*
* NOTE: If you change these, also change the error_reporting() code below
*
*/
define('ENVIRONMENT', 'development');
/*
*---------------------------------------------------------------
* ERROR REPORTING
*---------------------------------------------------------------
*
* Different environments will require different levels of error reporting.
* By default development will show errors but testing and live will hide them.
*/
if (defined('ENVIRONMENT'))
{
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
break;
case 'testing':
case 'production':
error_reporting(0);
break;
default:
exit('The application environment is not set correctly.');
}
}
或者手动尝试使用 ini_set() 将错误处理的配置正确设置为 on
// change settings for error handler to show errors
// $this setup is used for checking errors for development to be shown....
ini_set('display_errors', 1);
ini_set('display_startup_errors',1);
error_reporting(E_ALL);