|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2003-12-08 13:22 UTC] derick@php.net
[2004-09-29 09:32 UTC] php at nowhere dot net
[2004-09-29 09:42 UTC] tony2001@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 13:00:02 2025 UTC |
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