#26554 [Opn]: __get($variable) do not work.
| From: | derick@php.net | Date: | Mon, 08 Dec 2003 18:22:23 +0000 |
| Subject: | #26554 [Opn]: __get($variable) do not work. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-51812@lists.php.net to get a copy of this message | ||
ID: 26554
Updated by: derick@php.net
Reported By: jonas at gauffin dot org
Status: Open
-Bug Type: Class/Object related
+Bug Type: Feature/Change Request
Operating System: winxp
PHP Version: 5.0.0b2 (beta2)
New Comment:
This is not really a bug, making it a feature request.
Previous Comments:
------------------------------------------------------------------------
[2003-12-08 13:20:14] jonas at gauffin dot org
Description:
------------
__get do not work as I expected. I think that it should override member
variables (and return them).
Reproduce code:
---------------
class testClass
{
private $myTest;
function __get($memberVariable)
{
if ($memberVariable == 'myTest')
return $this->myTest;
}
}
$test = new testClass;
echo $test->myTest;
Expected result:
----------------
imho that's valid code. I do not want to change the variables to public
since they are readonly. One way to do it would be to add a prefix to
the member variables, but since $this have to be used to access the
variables that would produce ugly code.
Actual result:
--------------
PHP Fatal error: Cannot access private property testclass::$myTest in
E:\projects\inetpub\progga.se\test.php on line 46
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26554&edit=1