Can't use method return value in write context

后端 未结 8 1233
野趣味
野趣味 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:36

    I'm not sure if this would be a common mistake, but if you do something like:

    $var = 'value' .= 'value2';
    

    this will also produce the same error

    Can't use method return value in write context

    You can't have an = and a .= in the same statement. You can use one or the other, but not both.

    Note, I understand this is unrelated to the actual code in the question, however this question is the top result when searching for the error message, so I wanted to post it here for completeness.

提交回复
热议问题