php - 解析错误: unexpected '@' symbol in constant function in php

标签 php function php-parse-error

在我的项目中,当我尝试安装软件时,在安装的最后一步出现解析错误

解析错误为

Parse error: syntax error, unexpected '@' in /path/to/server/subfolder1/projectfoldername/subfolder/filename.php on line 21

该文件的特定行中的编码是

if(@constant($matches[1][0]) != @$matches[1][0]){
        if(!empty(@constant(@$matches[1][0])) & !empty(@$matches[0][0]) & !empty(@$design_m_r[$key])){
           $design_m_r[$key] = @str_replace($matches[0][0], constant($matches[1][0]), $design_m_r[$key]);
         }
        }

我们网站的 php 版本是 php 5.3.28。我试图搜索这个错误。但我没有得到任何解决方案。一些论坛将此错误描述为“这是高级 php 版本功能。所以这应该不支持 php 5.3.28 版本”。但我查了一下,没有版本使用这种功能。

最佳答案

您不能像这样使用@ 错误抑制运算符。

来自 PHP 文档..

The @-operator works only on expressions. A simple rule of thumb is: if you can take the value of something, you can prepend the @ operator to it. For instance, you can prepend it to variables, function and include calls, constants, and so forth. You cannot prepend it to function or class definitions, or conditional structures such as if and foreach, and so forth.

此外,passing arbitrary expressions仅从 PHP 5.5 起才允许 on empty

关于php - 解析错误: unexpected '@' symbol in constant function in php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22298736/

相关文章:

python - 更快地调用函数求值

php - 如何更改 LimeSurvey 单选按钮样式?

javascript - Laravel 5.6 更新模型中表单的记录未提交

php - 从 Facebook Graph API 获取第三方帖子

javascript - JSLint 无法识别 getElementById

php - 一个类可以扩展一个类并实现一个接口(interface)吗

php - Doctrine DQL 子查询给出零结果

function - Elisp 函数返回值

PHP 在 XML 开始标记上抛出错误

php - 尝试在函数中使用私有(private)变量时的错误代码