unset不能return 因爲返回的是void

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.
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章