停止向浏览器打印php错误消息 [英] Stop printing php error messages to browser

查看:149
本文介绍了停止向浏览器打印php错误消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用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 [$短语];

} catch(Exception $ e){
error_log(找不到翻译文件中的任何条目。$ phrase。。$ e);
返回$短语;

}

return $ tr_text;
}

为了停止此行为,我应该如何进行配置?



我已经尝试在php.ini中设置display_errors = Off和display_errors = 0。没有区别(我做了重启httpd)。

解决方案

  display_errors = Off 
pre>

在php.ini将让您保持您的系统日志错误,但不写入浏览器。


I'm using PHP 5.3, CentOS 6.2, httpd 2.2.15, NetBeans 7.0.1 (running remotely via ftp).

I want to stop printing error messages to the browser, it's enough that it prints to the error_log of httpd.

I thought by doing try/catch I would decide on my own how to handle the error but it still prints to both error_log and browser.

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;
    } 

How should I configure in order to stop this behaviour?

I have tried setting display_errors=Off and display_errors=0 in php.ini. No difference (I did restart httpd).

解决方案

display_errors = Off

in php.ini will let you keep your syslog errors, but write nothing to the browser.

这篇关于停止向浏览器打印php错误消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆