|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2005-03-06 18:28 UTC] sniper@php.net
[2005-03-09 19:02 UTC] m dot gehin at adan dot asso dot fr
[2005-04-05 21:54 UTC] tony2001@php.net
[2005-04-26 15:24 UTC] dmitry@php.net
|
|||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 13 08:00:02 2025 UTC |
Description: ------------ When using the ++ operator on a property that is overloaded, the value inside the class is incremented *BEFORE* the call to the __set() method. Reproduce code: --------------- class overloaded { private $values; function __construct() { $this->values = array('a' => 0); } function __set($name, $value) { print "<br>set $name = $value ($name was ".$this->values[$name].")"; $this->values[$name] = $value; } function __get($name) { print "<br>get $name (returns ".$this->values[$name].")"; return $this->values[$name]; } } $test = new overloaded(); $test->a++; // __get(), then __set() Expected result: ---------------- get a (returns 0) set a = 1 (a was 0) Actual result: -------------- get a (returns 0) set a = 1 (a was 1)