Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I disable notices and warnings in PHP within the .htaccess file?

Tags:

php

.htaccess

I just want to only turn on PHP errors and disable all notices and warnings in PHP files.

like image 667
nic Avatar asked Dec 28 '11 07:12

nic


People also ask

How do I hide warnings and notices in PHP?

In the current file, search for the line of code error_reporting. There will be a line of Default Value: E_ALL as shown below: Replace this line of code with Default Value: E_ALL & ~E_NOTICE. It will display all the errors except for the notices.

How do I close a warning in PHP?

in Core Php to hide warning message set error_reporting(0) at top of common include file or individual file.


2 Answers

It is probably not the best thing to do. You need to at least check out your PHP error log for things going wrong ;)

# PHP error handling for development servers php_flag display_startup_errors off php_flag display_errors off php_flag html_errors off php_flag log_errors on php_flag ignore_repeated_errors off php_flag ignore_repeated_source off php_flag report_memleaks on php_flag track_errors on php_value docref_root 0 php_value docref_ext 0 php_value error_log /home/path/public_html/domain/PHP_errors.log php_value error_reporting -1 php_value log_errors_max_len 0 
like image 69
imp Avatar answered Oct 11 '22 02:10

imp


If you are in a shared hosting plan that doesn't have PHP installed as a module you will get a 500 server error when adding those flags to the .htaccess file.

But you can add the line

ini_set('display_errors','off'); 

on top of your .php file and it should work without any errors.

like image 35
Fortes Avatar answered Oct 11 '22 00:10

Fortes