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).
You need to change the php.ini setting
display_errors
tooff
or0
. You can either do this in your actual php.ini, with a .htaccess file, or by calling this at the start of the script:If error appears only in one line it is possible to prevent error display with adding sign @ to start of that line.
@YOUR_CUSTOM_COMMAND
Example:
Wheter or not PHP errors are sent to the browser is determined by the php.ini setting:
display_errors
. Set it toOff
to avoid it being output. This file is usually located under/etc/php.ini
or/etc/php5/php.ini
See
display_errors
directivehttp://www.php.net/manual/en/errorfunc.configuration.php
Try adding the following to the top of your script:
This should set the error reporting to none and override the servers php.ini settings (which sometimes ignore your error_reporting(0) )
in php.ini will let you keep your syslog errors, but write nothing to the browser.