#26554 [Opn->Csd]: __get($variable) do not work.

From: Date: Wed, 29 Sep 2004 07:42:27 +0000
Subject: #26554 [Opn->Csd]: __get($variable) do not work.
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-66856@lists.php.net to get a copy of this message
ID: 26554 Updated by: tony2001@php.net Reported By: jonas at gauffin dot org -Status: Open +Status: Closed Bug Type: Feature/Change Request Operating System: winxp PHP Version: 5.0.0b2 (beta2) New Comment: Sample code work ok now -> closed. Previous Comments: ------------------------------------------------------------------------ [2004-09-29 09:32:41] php at nowhere dot net This test code appears to work now. Should this be closed? ------------------------------------------------------------------------ [2003-12-08 13:22:22] derick@php.net This is not really a bug, making it a feature request. ------------------------------------------------------------------------ [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

« previous php.bugs (#66856) next »