Nic*_*oft 11 php linux apache error-handling netbeans
我使用的是PHP 5.3,CentOS 6.2,httpd 2.2.15,NetBeans 7.0.1(通过ftp远程运行).
我想停止向浏览器打印错误消息,它足以打印到httpd的error_log.
我想通过try/catch我会自己决定如何处理错误,但它仍然会打印到error_log和浏览器.
function smic_gettext($phrase){
try{
$tr_text = $this->language_array[$phrase];
} catch(Exception $e){
error_log("Couldn't find any entry in the translation file for ".$phrase.". ".$e);
return $phrase;
}
return $tr_text;
}
Run Code Online (Sandbox Code Playgroud)
我应该如何配置以阻止此行为?
我试过在php.ini中设置display_errors = Off和display_errors = 0.没有区别(我确实重启了httpd).
Eug*_*eck 12
display_errors = Off
Run Code Online (Sandbox Code Playgroud)
在php.ini中,您可以保留syslog错误,但不向浏览器写任何内容.
您需要将php.ini设置更改display_errors为off或0.您可以在实际的php.ini中使用.htaccess文件执行此操作,也可以在脚本的开头调用它:
ini_set('display_errors', '0');
Run Code Online (Sandbox Code Playgroud)
是否发送PHP错误发送到浏览器由php.ini设置确定:display_errors.将其设置Off为避免输出.此文件通常位于/etc/php.ini或/etc/php5/php.ini
尝试将以下内容添加到脚本顶部:
ini_set('display_errors',0);
Run Code Online (Sandbox Code Playgroud)
这应该将错误报告设置为none并覆盖服务器php.ini设置(有时会忽略您的error_reporting(0))
| 归档时间: |
|
| 查看次数: |
8729 次 |
| 最近记录: |