PHP:这行代码有什么问题?
if($player[$x]->name == $p->name || $player[$x]->name == $target) unset $player[$x]; //<-- line 215
注释掉这一行会删除错误:
PHP Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /path/script.php on line 215
但我不知道它是否期待 (,我是否遗漏了一些明显的东西?
if($player[$x]->name == $p->name || $player[$x]->name == $target) unset $player[$x]; //<-- line 215
commenting out this line removes the error:
PHP Parse error: syntax error, unexpected T_VARIABLE, expecting '(' in /path/script.php on line 215
But I don't see were it's expecting a (, am I missing something obvious?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
unset()
是一种需要括号的语言构造;您必须使用unset($player[$x]);
。unset()
is a language construct that requires parentheses; you must useunset($player[$x]);
.unset 是一个函数,您需要用括号调用它,如下所示:
unset( $player[ $x ] )
你最好将代码分成不同的行,以便更容易地查看问题所在。
unset is a function, you need to call it with parentheses, like this:
unset( $player[ $x ] )
you'd better separate your code to different lines to see where the problem is more easily.
取消设置需要括号:
Unset requires the parentheses: