Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop printing php error messages to browser

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).

like image 541
Nicsoft Avatar asked Jan 19 '12 14:01

Nicsoft


People also ask

How do I turn off PHP error reporting?

To turn off or disable error reporting in PHP, set the value to zero. For example, use the code snippet: <? php error_reporting(0); ?>

How do I change PHP INI display errors?

The quickest way to display all php errors and warnings is to add these lines to your PHP code file: ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); The ini_set function will try to override the configuration found in your php. ini file.

How do I turn off PHP warnings in WordPress?

Either way, you're looking for the “WP_DEBUG” portion of the wp-config. php file. Click the “Save Changes” button in the top right. Once the file is saved, this will disable the PHP warnings in WordPress.


1 Answers

display_errors = Off

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

like image 196
Eugen Rieck Avatar answered Oct 26 '22 04:10

Eugen Rieck