unset不能return 因为返回的是void

来源:互联网 发布:安卓chroot运行linux 编辑:程序博客网 时间:2024/06/05 05:33
Note that since unset() returns void, you can't do this:

isset($some_var) && unset($some_var);

You'll get: Parse error: syntax error, unexpected T_UNSET in ...

The reason is because it would parse as
<bool> && <void>;
which is not a valid PHP statement.

Thus, the only alternative is to actually use if statement.
0 0
原创粉丝点击