【问题标题】:PHP Catchable fatal error: Object of class WP_Error could not be converted to string in wpPHP Catchable 致命错误:WP_Error 类的对象无法在 wp 中转换为字符串
【发布时间】:2017-06-26 21:06:27
【问题描述】:

问题

PHP 可捕获的致命错误:WP_Error 类的对象无法在第 1249 行的 /home/faceboo2/netbusinesseurope.com/wp-includes/kses.php 中转换为字符串

$string = preg_replace( '/[\x00-\x08\x0B\x0C\x0E-\x1F]/', '', $string );

PHP 版本 = 7.0.0

【问题讨论】:

标签: php string


【解决方案1】:

每当您收到“无法转换为字符串”错误时,这是​​因为您尝试在需要字符串的上下文中使用不是字符串的内容。 PHP 将尝试转换它是什么,但一个对象不能被转换,除非它有一个__toString 方法。

在您的情况下,$string 似乎是一个 WP_Error 对象。该行之前可能出现了问题,因为$string 调用该对象似乎很奇怪,但基于the Wordpress documentation,您应该能够获得实际的错误消息字符串:

$message = $string->get_error_message()

然后你可以用它做字符串的东西。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多