在我的项目中,当我尝试安装软件时,在安装的最后一步出现解析错误
解析错误为
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/