Can't use method return value in write context

后端 未结 8 1333
野趣味
野趣味 2020-11-22 01:52

I would think the following piece of code should work, but it doesn\'t (Edited: Now works in PHP 5.5+):

if (!empty($r->getError()))
         


        
8条回答
  •  天涯浪人
    2020-11-22 02:47

    Prior to PHP 5.5, the the PHP docs used to say:

    empty() only checks variables as anything else will result in a parse error

    In PHP < 5.5 you weren't able use empty() directly on a function's return value. Instead, you could assign the return from getError() to a variable and run empty() on the variable.

    In PHP >= 5.5 this is no longer necessary.

提交回复
热议问题