PHP - Indirect modification of overloaded property

前端 未结 8 1704
悲哀的现实
悲哀的现实 2020-11-28 08:38

I know this question has been asked several times, but none of them have a real answer for a workaround. Maybe there\'s one for my specific case.

I\'m building a map

8条回答
  •  感动是毒
    2020-11-28 08:50

    I've had this same error, without your whole code it is difficult to pinpoint exactly how to fix it but it is caused by not having a __set function.

    The way that I have gotten around it in the past is I have done things like this:

    $user = createUser();
    $role = $user->role;
    $role->rolename = 'Test';
    

    now if you do this:

    echo $user->role->rolename;
    

    you should see 'Test'

提交回复
热议问题