Home    Articles

 

Warning: Creating default object from empty value in ...

 

If you have this error you are trying to create an object property in an non existing object.

Here is one example:

$this->user->data->name ='Username';

If $this->user is an object but the data is not an object you will get this error : "Warning: Creating default object from empty value in..."

To solve this, you have to create the $this->user->data as object.

$this->user->data = new stdClass();

Now you can assign the name property to the $this->user->data.

by