#25199 [Com]: $this->a doesn't call $this->__get('a')
| From: | kyle at putnamcabinets dot com | Date: | Thu, 16 Oct 2003 03:54:25 +0000 |
| Subject: | #25199 [Com]: $this->a doesn't call $this->__get('a') | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-49072@lists.php.net to get a copy of this message | ||
ID: 25199
Comment by: kyle at putnamcabinets dot com
Reported By: thomas dot hebinck at digionline dot de
Status: Open
Bug Type: Zend Engine 2 problem
Operating System: Linux
PHP Version: 5CVS-2003-08-21 (dev)
New Comment:
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".
Previous Comments:
------------------------------------------------------------------------
[2003-08-21 13:05:24] 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 = ""
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25199&edit=1