php - Wordpress:“警告:非法字符串偏移”在多个地方
问题描述
希望你们能在这里帮助我。在我的 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'])
检查给定变量中是否存在(或不存在)索引。
推荐阅读
- python - 如何在 Django 中处理来自 DataTables Editor 的数据?
- python - @Eclipse PyDev Boost.Python.ArgumentError:Python 参数类型与 C++ 签名不匹配:
- php - 会话代码在 php 中不起作用
- python - 不规则矩形网格上的python pcolor
- objective-c - 使用谓词 iOS SDK 从字典数组中过滤图像
- android - Gradle 库冲突
- ios - 在横向模式下旋转后状态栏左侧为白色矩形
- ruby - Rspec 多个规范文件夹
- php - Authorize.net 商户登录ID或密码无效或账号无效
- sql - 如何在 Google BigQuery 中使用 UNNEST 函数获取 COUNT?