|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-01-28 23:30 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Dec 17 06:00:01 2025 UTC |
Description: ------------ Some bugs with __get(), __set() Reproduce code: --------------- class Test1 { public function __construct() { } public function test() { $this->Prop = 'test'; echo $this->Prop; echo isset($this->Prop); echo !empty($this->Prop); echo $this->Prop; } } class Test2 extends Test1 { private $prop; public function __construct() { } public function __get($name) { $name{0} = strtolower($name{0}); // Property called with first symbol upper case switch ($name) { case "prop" : return $this->prop; break; } } public function __set($name, $value) { $name{0} = strtolower($name{0}); // Property called with first symbol upper case switch ($name) { case "prop" : $this->prop = $value; break; } } } $obj = new Test2(); $obj->test(); Expected result: ---------------- test {false} {false} test Actual result: -------------- test 1 1 test ??????? ??????? ?? ???????????? ???????????? ?????????, ??? ???????? ???????? ? ?????????? ????? ?????? ? ?????????? ????????? ????????? ???????? ? ???????????? ????? ??????. Sory, my english very bad :(