Meaning of "Can't use method return value in write context"

Possible Duplicate:
Can't use method return value in write context

I sometimes encountered this error Can't use method return value in write context . However, I don't know what does WRITE CONTEXT means in this sentence. Could someone tell me a little general explaination of it.

Thank you.

The code for this error if you want to refer to is on line if(empty($this->loadUser())) However just to clarify, I just want to find out the meaning of "write context":

public function verify()
{
    if(empty($this->loadUser()))
        $this->addError('username','Incorrect username.');
    else
    {
        $user = $this->loadUser();
        $project = $this->loadProject($pid);

        $project->associateUserToProject($this->loadUser());
        $project->associateUserToRole($this->role, $this->user->id)

    }
}

public function loadUser() {
    return User::model()->findByAttributes(array('username'=>$this->username));
}

empty () is not a function really. It is a construct or macros, if you please. It means you cannot pass an object to it as argument. Just pure variables.

$is_use = $this->loadUser();
if (empty ($is_use))
{
   ...
}

empty only takes variables as an arg. empty() only checks variables as anything else will result in a parse error.

http://php.net/manual/en/function.empty.php

链接地址: http://www.djcxy.com/p/58432.html

上一篇: 在写入上下文Laravel 4中不能使用函数返回值

下一篇: “在写入上下文中不能使用方法返回值”的含义