php三元运算符给出错误
发布时间:2020-12-13 17:45:14 所属栏目:PHP教程 来源:网络整理
导读:在 PHP中,如果我有这样的三元组: $my_thing = $this-myAttribute ? $this-myAttribute : "No attribute was set."; 它可以缩写为这样吗? $my_thing = $this-myAttribute ?: "No attribute was set." 我以为我记得PHP在它的三元组中支持这个,但现在我收到了
在
PHP中,如果我有这样的三元组:
$my_thing = $this->myAttribute ? $this->myAttribute : "No attribute was set."; 它可以缩写为这样吗? $my_thing = $this->myAttribute ?: "No attribute was set." 我以为我记得PHP在它的三元组中支持这个,但现在我收到了一个错误. 解决方法
PHP 5.3及更高版本支持它.从
PHP.net起
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |