|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2006-07-24 07:37 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Nov 03 07:00:01 2025 UTC |
Description: ------------ When using overloading with the special function __set, and passing the value by reference, the overload is ignored, and a new attribute for the class object is created. I'm not sure if this is a bug, but I couldn't find anything like it in the documentation, or in the bug list. Appreciate the help. []'s Reproduce code: --------------- class A { private $v; function __construct() { echo "constructing...\n"; } function __set($key, $value) { echo "setting ".$key."\n"; $this->v[$key] = $value; } } $foo = "bar"; $a = new A; echo "without reference:\n"; $a->user = $foo; echo "with reference:\n"; $a->user =& $foo; var_dump($a); Expected result: ---------------- constructing... without reference: setting user with reference: object(A)#1 (2) { ["v:private"]=> array(1) { ["user"]=> &string(3) "bar" } } Actual result: -------------- constructing... without reference: setting user with reference: object(A)#1 (2) { ["v:private"]=> array(1) { ["user"]=> string(3) "bar" } ["user"]=> &string(3) "bar" }