nic
nic

Reputation: 939

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

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

Upvotes: 44

Views: 153668

Answers (6)

user5637954
user5637954

Reputation: 29

Use:

ini_set('display_errors','off');

It is working fine in WordPress' wp-config.php.

Upvotes: 2

Mohamed Badr
Mohamed Badr

Reputation: 59

I used ini_set('display_errors','off'); and it worked great.

Upvotes: 0

Rich
Rich

Reputation: 69

Fortes is right, thank you.

When you have a shared hosting it is usual to obtain an 500 server error.

I have a website with Joomla and I added to the index.php:

ini_set('display_errors','off');

The error line showed in my website disappeared.

Upvotes: 6

Fortes
Fortes

Reputation: 938

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.

Upvotes: 29

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100175

Try:

php_value error_reporting 2039

Upvotes: 24

imp
imp

Reputation: 1130

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

Upvotes: 60

Related Questions