如何阻止 PHP 通知出现在 WordPress 中?

发布于 2024-08-03 07:28:26 字数 663 浏览 7 评论 0原文

我知道 error_reporting(0);ini_set('display_errors', false);,但是 WordPress 中出现了一个通知:

注意:/var/www/vhosts/treethink.net/subdomains/parkridge/httpdocs/wp-includes/formatting.php359 行中的数组到字符串转换>

< em>仅出现在wordpress中,而不出现在网站的任何其他页面中。

我检查了 phpinfo(),一切都已设置,因此不会显示错误。为什么这个还出现?

这是生成错误的行:

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

确实更改了 WordPress 中的一些内容,以更改图库的工作方式。但不是这个函数,而且我认为我也没有更改对此函数的任何调用。除了出现的通知之外,一切似乎都运行得很好,我只需要隐藏这个错误即可。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

如梦初醒的夏天 2024-08-10 07:28:26

您需要编辑您的:

wp-config.php

文件并在此处修改以下内容:

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

否则 WordPress 会覆盖 PHP.INI 设置的警报

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

絕版丫頭 2024-08-10 07:28:26

2015 年 1 月使用最新的 Wordpress,以上都不适合我。

在Wordpress的mu-plugins文件夹中创建一个php文件是有效的,例如:

<?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 )); 

只需将其命名为您想要的任何名称...

我从这里得到了答案:

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

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/

英雄似剑 2024-08-10 07:28:26

在 wp-config.php 中添加以下行:

define('WP_DEBUG_DISPLAY', false);

这将启用或禁用在页面上显示通知和警告。这里有此选项以及一些相关选项的更完整描述:

http://codex.wordpress.org/Debugging_in_WordPress

In wp-config.php add this line:

define('WP_DEBUG_DISPLAY', false);

That will enable or disable the display of notices and warnings to the page. There is a fuller description of this option, and some related options, here:

http://codex.wordpress.org/Debugging_in_WordPress

糖粟与秋泊 2024-08-10 07:28:26

大多数时候,这些都无需担心(尽管插件/主题开发人员应该了解这些,以便他们可以在将来的版本中修复它们)。大多数时候,在生产站点上,PHP 警告和通知无需担心。
其中一些甚至可以生成,因为开发人员必须保持与旧版本 WordPress 以及旧 PHP 版本的兼容性。

define('WP_DEBUG', false);

如果

ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

您只需在 wp-config.php 文件将 WP_DEBUG 设置为 false 就可以了。这些不会以任何方式影响您的网站。

但问题是,有时上述方法不起作用。
在强制显示 PHP 警告和通知的廉价共享主机上,大多数情况下都会发生这种情况。
在这种情况下,您可以替换 wp-config.php 文件中的这一行:

Most of the time these are nothing to worry about (though the plugin/theme developer should know about these so that they may fix them in a future release). PHP warnings and notices are nothing to worry about on a production site most of the time.
Some of these can even be generated because the developer has to keep compatibility with older versions of WordPress as well as older PHP versions.

define('WP_DEBUG', false);

with this

ini_set('log_errors','On');
ini_set('display_errors','Off');
ini_set('error_reporting', E_ALL );
define('WP_DEBUG', false);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);

If you simply set WP_DEBUG to false in your wp-config.php file you should be fine. These don’t affect your site in any way.

However, the problem is that some times the above does not work.
That can happen most times on cheap shared hosts that force displaying PHP warnings and notices.
In that case, you can replace this line from your wp-config.php file:

待天淡蓝洁白时 2024-08-10 07:28:26

如果您只想隐藏来自此函数的错误,您可以使用

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

}

if you want to hide only errors that comes from this function you can use

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

}
2024-08-10 07:28:26
/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 */
define('WP_DEBUG', false);

// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', false);

// Disable display of errors and warnings 
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);

我使用的并且它适用于最新的 WordPress 版本。

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 */
define('WP_DEBUG', false);

// Enable Debug logging to the /wp-content/debug.log file
define('WP_DEBUG_LOG', false);

// Disable display of errors and warnings 
define('WP_DEBUG_DISPLAY', false);
@ini_set('display_errors', 0);

What I use and it works with the latest WordPress version.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文