How can I stop PHP notices from appearing in wordpress?


Question

I know about error_reporting(0);, and ini_set('display_errors', false);, but there is a notice appearing in wordpress:

Notice: Array to string conversion in /var/www/vhosts/treethink.net/subdomains/parkridge/httpdocs/wp-includes/formatting.php on line 359

it only appears in wordpress, not in any other pages of the site.

I checked phpinfo(), and everything is set so that errors are not displayed. Why does this one still show up?

Here is the line that generates the error:

function wp_check_invalid_utf8( $string, $strip = false ) {
    $string = (string) $string;

I did change some thing in wordpress, to change how the gallery worked. But not this function, and I don't think I changed any calls to this function either. Aside from the notice appearing, everything seems to operate perfectly fine, I just need to get this error to hide.

1
26
8/20/2009 7:41:08 PM

Accepted Answer

You need to edit your:

wp-config.php

file and modify the following here:

error_reporting(0);
@ini_set('display_errors', 0);

otherwise Wordpress overwrites the ALERTS set by PHP.INI

51
2/19/2013 3:16:28 AM

Jan 2015 with latest Wordpress, none of the above works for me.

Creating a php file in mu-plugins folder of Wordpress worked, like :

<?php
error_reporting(E_ALL &  ~( E_NOTICE | E_USER_NOTICE | E_STRICT | 
E_DEPRECATED | E_USER_DEPRECATED | E_WARNING | E_CORE_WARNING | 
E_USER_WARNING | E_COMPILE_WARNING | E_PARSE )); 

Just name it anything you want ...

i got the answer from here :

https://wycks.wordpress.com/2013/12/05/how-to-remove-error-notices-using-wordpresss-wp_debug/


Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon