我有一个非常简单的 IF 语句...
if ($key == "listingURL" or
$key == "interiorColor" or
$key == "engine" or
$key == "transmission" or
$key == "stockNumber" or
$key == "VIN") {
// Do thing
}
但是我收到一个错误...
[23-Apr-2015 13:12:01 UTC] PHP Parse error: syntax error, unexpected T_VARIABLE in xxx on line xxx
这是哪一行...
$key == "stockNumber" or
OR 的最大数量是否有限制,或者我是否遗漏了一些正对着我的东西?
最佳答案
"Is there a limit to the maximum amount of OR's, or am I missing something staring me right in the face?"
不,没有。原因是因为你有一个隐藏角色:
$key == "transmission" or ? <= right there
这是
成为 Unicode ZERO WIDTH NO-BREAK SPACE性格。
重写:
if ($key == "listingURL" or
$key == "interiorColor" or
$key == "engine" or
$key == "transmission" or
$key == "stockNumber" or
$key == "VIN") {
// Do thing
}
旁注:
来自 comments :
I'll confirm this as the correct answer as soon as the time limit is up! Thank you so much for the help. I use Sublime Text 3, is there some easy way to detect these hidden characters? – SoWizardly 19 mins ago
对于 Notepad++
有一个插件叫做:HEX-Editor
。
您可以通过以下路径下载它:扩展 -> 插件管理器 -> 可用。只需选中 HEX-Editor
的组合框,然后单击安装。在此之后,您可以将文件 View 更改为十六进制。
对于 Sublime Text
还有一个 plugin ,这也是一样的。
关于php - 简单的 PHP If 语句错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29824738/