PHP 4.0 Bug #4661: Class variable corruption

From: Date: Mon, 29 May 2000 10:50:24 +0000
Subject: PHP 4.0 Bug #4661: Class variable corruption
Groups: php.dev 
Request: Send a blank email to php-dev+get-19663@lists.php.net to get a copy of this message
From: Jim.Moores@quickstone.com Operating system: Redhat 6.1 PHP version: 4.0.0 Release PHP Bug Type: Scripting Engine problem Bug description: Class variable corruption Hi guys, I think I've found a nasty bug, at first I thought it was bug #2467, but you claimed to have fixed that last october. I tried upgrading from RC1 to 4.0.0 but it didn't help (and I am sure the upgrade worked becuase phpinfo() reports the new version). I enclose a short script to demonstrate the problem. The script should output the same value twice, but when another variable is written to in bewteen echo's, it corrupts the value. We have had a problem with our compiler, egcs 2.91.66 needing to be run repeatedly on the php-4.0.0 release sources, but I don't think its related..? Anyway, here it is - it should print "1 1", but instead it prints "1 2". It also acts differently if you change the name of the constructor function (so it's no longer the constructor), you get a different value, I think). <? 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(); ?> Anything you could do would be greatly appreciated, I'm having real trouble developping with this bug! Thanks Jim Moores, Quickstone Systems, UK. PS. our configuration is just the same as in the quick install guide.

« previous php.dev (#19663) next »