这是一个测试列表(所有错误包括表达式):
php > isset(1); // integer
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in php shell code on line 1
php > isset('string'); // string
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in php shell code on line 1
php > isset(null); // null
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in php shell code on line 1
php > isset(['q']); // array
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in php shell code on line 1
php > isset(1==1); // expression
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in php shell code on line 1
php > isset("null !== expression")
php > ;
Fatal error: Cannot use isset() on the result of an expression (you can use "null !== expression" instead) in php shell code on line 1
但是在用空测试时:
empty(1); // integer
empty('string'); // string
empty(null); // null
empty(['q']); // array
empty(1==1); // expression
empty("null !== expression");
没有错误..我知道手册中的警告
Warning
isset() only works with variables as passing anything else will result in a parse error. For checking if constants are set use the defined() function.
但是想知道为什么反正..为什么会那样?
答案 0 :(得分:0)
[解决] 它将作为即将发布的php7补丁的一个功能修复