在处理错误时使用.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()来正确设置上
// 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);
处理错误的配置'display_startup_errors'将是什么人将要为自己。我不想要一个PHP框架来尝试控制http服务器。话虽如此,我不知道这是一个简单的方法来完成你在说什么。 htaccess只是一个iirc指令文件。 – castis 2013-03-27 00:52:44
你可能是对的,但这个框架不会大规模分发;-)。谢谢。 – dirk 2013-03-27 00:54:13
为什么使用.htaccess来显示错误而不是php的ini_se()配置? – 2013-03-27 00:55:49