#38716 [Opn->Bgs]: Fatal error: Cannot access private property

From: Date: Mon, 04 Sep 2006 21:04:30 +0000
Subject: #38716 [Opn->Bgs]: Fatal error: Cannot access private property
References: 1  Groups: php.doc 
Request: Send a blank email to phpdoc+get-969373908@lists.php.net to get a copy of this message
ID: 38716 Updated by: tony2001@php.net Reported By: mmerlone at gmail dot com -Status: Open +Status: Bogus Bug Type: Documentation problem Operating System: Ubuntu linux 6.06 2.6.15-26-686 PHP Version: 5.1.6 New Comment: Yes, __set() does change the private property, but your code tries to modify the property directly and this is totally different case. The documentation is correct. Previous Comments: ------------------------------------------------------------------------ [2006-09-04 20:54:44] mmerlone at gmail dot com So, if it works as expected, the documentation should be fixed, since the example shows the __set changind a private variable. ------------------------------------------------------------------------ [2006-09-04 20:17:40] tony2001@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php ------------------------------------------------------------------------ [2006-09-04 20:08:51] mmerlone at gmail dot com Description: ------------ Overloading method __set does not work for private variables as the example "Example 19-20. overloading with __get, __set, __isset and __unset example" from http://us3.php.net/manual/en/language.oop5.overloading.php . This is the same of bug #34893 (http://bugs.php.net/bug.php?id=34893) which claims to be fixed, but is not. Reproduce code: --------------- <? class bla{ private $variavel; function bla(){ } function __set($vn, $vv){ $this->$vn = $vv; } } $bla = new bla(); $bla->variavel = 1; echo "bla->variavel=".$bla->variavel."\n"; ?> Expected result: ---------------- bla->variavel=1 Actual result: -------------- Fatal error: Cannot access private property bla::$variavel in /devel/testes/private.php on line 14 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=38716&edit=1

« previous php.doc (#969373908) next »