Re: PHP 4.0 Bug #4661: Class variable corruption
| From: | Stanislav Malyshev | Date: | Mon, 29 May 2000 10:54:45 +0000 |
| Subject: | Re: PHP 4.0 Bug #4661: Class variable corruption | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-19664@lists.php.net to get a copy of this message | ||
>> <?
>> class ProductList {
>>
>> var $grp_index;
>> var $name_index;
>>
>> /* Constructor */
>> function ProductList() {
>> $this->$grp_index = 1; # Yuck!!!
>> }
>>
>> function nextEntry() {
>> echo $this->$grp_index;
>> echo "<br>";
>> $this->$name_index = 2;
>> echo $this->$grp_index;
>> }
>> }
>> $pl = new ProductList;
>> $pl->nextEntry();
>> ?>
>>
This is not a bug. You are working whith class variable which name is
contained in $grp_index and $name_index, which both are empty - this means
you are working with $pl-><NULL> variable. If you want to get to
$this->name_index, write $this->name_index, without extra dollar. Please
read http://www.zend.com/manual/ or http://www.php.net/manual/ for syntax
about calling class variables. Also, please close this bug since it is not
a bug (at least, not a bug in PHP).
--
Stanislav Malyshev stas@zend.com
+972-3-6139665