在處理錯誤時使用.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