【问题标题】:500: PHP Parse error: syntax error, unexpected '?' [duplicate]500:PHP 解析错误:语法错误,意外的“?” [复制]
【发布时间】:2025-12-08 03:10:02
【问题描述】:

我在访问我的 froxlor 资源选项时遇到问题,它返回 500。检查日志后似乎是它的 froxlor 文件问题,但在更新之前它工作正常。 谁能帮我解决这个问题。

以下是我从日志文件中获取的日志

==> error.log https://domainname.de/froxlor/admin_index.php?s=e1f085be86e266d74ae77d82e88ec08b

==> access.log

有代码

if (! is_array($valoper) || ! isset($valoper['op']) || empty($valoper['op'])) {
    $condition .= $field . ' LIKE :' . $cleanfield;
    if (! is_array($valoper)) {
        $query_fields[':' . $cleanfield] = '%' . $valoper . '%';
    } else {
        $query_fields[':' . $cleanfield] = '%' . $valoper['value'] . '%';
    }
} elseif (in_array($valoper['op'], $ops)) {
    $condition .= $field . ' ' . $valoper['op'] . ':' . $cleanfield;
    //=====>Line288
    $query_fields[':' . $cleanfield] = $valoper['value'] ?? '';
} else {
    continue;
}
if ($first) {
    $first = false;
}

【问题讨论】:

    标签: php null-coalescing-operator


    【解决方案1】:

    我猜这个错误是由Null Coalescing Operator 引发的。这个运算符在 PHP 7.0 中引入。在 PHP 5.x.x 中,您需要在三元运算符中使用 isset()

    $query_fields[':' . $cleanfield] = isset($valoper['value']) ? $valoper['value'] : '';
    

    【讨论】: