Codeigniter中禁止A Database Error Occurred错误提示的方法
2014-06-12 11:40
676 查看
在默认的情况下,CodeIgniter会显示所有的PHP错误。但是当你开发程序结束时,你可能想要改变这个情况。
你会发现在index.php文件顶端有这个函数error_reporting(),通过它可以进行对错误的设置。 即使你关闭了错误报告,当有错误发生时,错误记录也不会停止。
所以,修改php.ini不能达到我们想要的效果。
下面是解决办法:
1. Codeigniter中禁止A Database Error Occurred错误提示
在CodeIgniter 用户指南中说到,设置 ENVIRONMENT 常量为 'development' 值将会允许所有PHP错误报告都输出到浏览器。 相反的,设置常量为 'production' 将会禁止所有错误报告的输出。
index.php中修改error_reporting:
define('ENVIRONMENT', 'production'); //默认是development
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.');
}
}
2. Codeigniter中禁止A PHP Error was encountered错误提示
config/database.php中修改数据库设置:
$db['default']['db_debug'] = FALSE;
您可能感兴趣的文章:
- CodeIgniter错误mysql_connect(): No such file or directory解决方法
- Codeigniter上传图片出现“You did not select a file to upload”错误解决办法
- Codeigniter出现错误提示Error with CACHE directory的解决方案
- codeigniter框架The URI you submitted has disallowed characters错误解决方法
- CI框架整合widget(页面格局)的方法
- CI框架出现mysql数据库连接资源无法释放的解决方法
- CI框架集成Smarty的方法分析
- CI框架中数据库操作函数$this->db->where()相关用法总结
- CI框架中redis缓存相关操作文件示例代码
- CodeIgniter记录错误日志的方法全面总结
相关文章推荐
- Codeigniter中禁止A Database Error Occurred及A PHP Error was encountered错误提示的方法
- Codeigniter中禁止A Database Error Occurred错误提示的方法
- Codeigniter中禁止A Database Error Occurred及A PHP Error was encountered错误提示的方法
- [Asp]解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法
- 解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法
- 解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法
- 解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法
- 解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法
- 解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法
- 解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法
- 解决IIS7中出现An error occurred on the server when processing the URL错误提示的方法
- Eclipse安装WindowBuilder提示错误:An error occurred while collecting items to be installed,解决方法
- Codeigniter中禁止A Database Error Occurred及A PHP E...
- 解决IIS7运行ASP提示错误:An error occurred on the server when processing the URL. Please contact the system administrator
- IIS7.0 调试ASP程序时候,程序有错误只提示"An error occurred on the server when processing the URL.Please contact the system administrator",看不到详细的提示的解决办法
- 将App通过XCode上传到AppStore 出现这个错误“An error occurred uploading to the iTunes Store”的解决方法
- iis7错误提示An error occurred on the server when processing the URL
- C# Winform 中webBrowser显示html内容时禁止错误提示的方法
- 将App通过XCode上传到AppStore出现这个错误“An error occurred uploading to the iTunes Store”的解决方法
- Codeigniter项目访问时出现错误提示Error with CACHE directory的解决方案