|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-08-21 13:05 UTC] thomas dot hebinck at digionline dot de
Description:
------------
A call of $this->a creates a new public variable instead of calling __get('a') - even if this call is just defined and never used. (same problem in beta 1)
Reproduce code:
---------------
<?
class foo {
function __get($property) {
switch ($property) {
case 'a':
return 'a';
break;
}
}
function bar() {
echo 'test';
return $this->a; // this is the "bad" line
}
}
$foo = new foo;
echo '$foo->a = "' . $foo->a . '"';
?>
Expected result:
----------------
$foo->a = "a"
Actual result:
--------------
$foo->a = ""
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 05:00:02 2025 UTC |
Interesting phenomenon: <? class foo { //var $a; // When uncommented, bug always occurs function __get($property) { echo "I behave properly\n"; } } $a = new foo; //$a->a = 'x'; // When uncommented, bug always occurs echo $a->a; ?> No output indicates the bug occurs, otherwise output is "I behave properly".