|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-12-16 12:46 UTC] dennis at inmarket dot lviv dot ua
[2005-01-10 23:34 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 20:00:01 2025 UTC |
Description: ------------ From outside a class, accessing a variable via a __get is identical to accessing one via a public member: $publ->varr vs. $gets->varr When trying to pass by reference, I would expect the corresponding __set to be called when the value originaly came from a __get. Instead, there is a Fatal error. Reproduce code: --------------- class PublicVar { public $varr; } class GetSetter { protected $data = array(); function __get($key) { return $this->data[$key]; } function __set($key, $value) { $this->data[$key] = $value; } } function set_by_ref(&$variable) { $variable = 'has been set, '; } $publ = new PublicVar(); set_by_ref($publ->varr); echo $publ->varr; $gets = new GetSetter(); set_by_ref($gets->varr); echo $gets->varr; Expected result: ---------------- has been set, has been set, Actual result: -------------- has been set Fatal error: Cannot access undefined property for object with overloaded property access in C:\eclipse\workspace\tmote\tmp_byref.php on line 27