php - WordPress: "Warning: Illegal string offset"在多个地方

标签 php wordpress error-handling syntax-error

希望你们能在这里帮助我。在我的 WordPress 安装中这些问题发生了什么,请参阅错误和引用的代码块。

错误:

Warning: Illegal string offset 'domain' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 583

Warning: Illegal string offset 'context' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 587

Warning: Illegal string offset 'singular' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'plural' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'context' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'domain' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 583

Warning: Illegal string offset 'context' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 587

Warning: Illegal string offset 'singular' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'plural' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

Warning: Illegal string offset 'context' in /home/customer/www/xxxxxxxx.xxx/public_html/wp-includes/l10n.php on line 588

代码:
function translate_nooped_plural( $nooped_plural, $count, $domain = 'default' ) {
    if ( $nooped_plural['domain'] ) {
        $domain = $nooped_plural['domain'];
    }

    if ( $nooped_plural['context'] ) {
        return _nx( $nooped_plural['singular'], $nooped_plural['plural'], $count, $nooped_plural['context'], $domain );
    } else {
        return _n( $nooped_plural['singular'], $nooped_plural['plural'], $count, $domain );
    }
}

最佳答案

Warning: Illegal string offset 'something'消息表示您正在尝试访问 $someVar['something'] 的值但它不存在。

为避免这种情况,您应始终使用 isset($someVar['something'])检查给定变量中是否存在(或不存在)索引。

关于php - WordPress: "Warning: Illegal string offset"在多个地方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60506431/

相关文章:

python - Instagram python bot,当我运行错误时如何关闭并重新启动?

c++ - 文件系统项目 "Member access into incomplete type"错误

php - 无法使用 PHPMailer 远程连接到我的电子邮件服务器

php - 文件上传php

php - 为什么 belongsTo() 返回 null?

javascript - 在 script-calls.php 中为定义的页面注册 js

php - 禁用跨域数据库

javascript - 使用 "file_put_contents"创建和编辑文件 javascript ?

带有 ACF 字段的 Wordpress 查询附件

grails - 如何在Grails中实现错误处理?