php - 致命错误:无法在 php wordpress 的写入上下文中使用函数返回值
问题描述
致命错误:无法在 /home2/property/teampropertyhunter.com/wp-content/plugins/google-analytics-for-wordpress/lite/includes/admin/wp-site-health.php 的写入上下文中使用函数返回值在第 106 行
public function is_tracking() {
if ( ! isset( $this->is_tracking ) ) {
$this->is_tracking = ! empty( monsterinsights_get_ua() );
}
return $this->is_tracking;
}
解决方案
在 php < 5.5 中(感谢@jszobody 指出),您不能像empty()
在函数返回时那样运行检查。您可以(至少)两种不同的方式来解决它:
在检查之前将值分配给变量:
if ( ! isset( $this->is_tracking ) ) {
$monsterUA = monsterinsights_get_ua();
$this->is_tracking = ! empty( $monsterUA );
}
或者,只使用值和三元运算符的存在:
if ( ! isset( $this->is_tracking ) ) {
$this->is_tracking = monsterinsights_get_ua() ? TRUE : FALSE;
}
推荐阅读
- jenkins - Junit 如何通过 Jenkins Docker 文件在 Jenkins 中配置
- php - MYSQL PHP 致命错误:未捕获的 mysqli_sql_exception:重复条目 '0' 中的键 'PRIMARY'
- javascript - 使用日期时间输入控件全球化验证问题
- pytest - 用于设置通过状态的pytest函数
- java - JavaFX TextArea get scrollTop percentage
- grails - 如何在 Grails 3 的显示视图中更改编辑和删除链接指向的内容?
- javascript - 我该如何制作它,以便它首先在 for 循环中检查特定元素?
- javascript - 向下滚动具有相同行类名称的所有表格元素
- c# - 具有损坏索引的对象的 Razor Pages 模型绑定列表
- c# - 一次尝试不同 JSON 消息的不同类 - C# 中的 catch 块