#26740 [Opn->Bgs]: Object Attribute Unexpectly Overwritten

From: Date: Mon, 29 Dec 2003 14:05:57 +0000
Subject: #26740 [Opn->Bgs]: Object Attribute Unexpectly Overwritten
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-52580@lists.php.net to get a copy of this message
ID: 26740 Updated by: derick@php.net Reported By: leo at myleo dot info -Status: Open +Status: Bogus Bug Type: Scripting Engine problem Operating System: Linux PHP Version: 5.0.0b2 (beta2) New Comment: Bogus code, use $this->domain and not $this->$domain. Previous Comments: ------------------------------------------------------------------------ [2003-12-29 08:43:01] leo at myleo dot info Description: ------------ In the source code, $this->filepath is overwritten unexpectly in the assignment $this->$tempFilepath=$this->$filepath.".tmp"; Reproduce code: --------------- class Zone{ var $path; // The path to store zone files var $filepath; // The zone file with absolute filepath var $tempFilepath; // Temporary file var $domain; // Domain object function Zone($domainTemp,$pathTemp){ if(preg_match("/^\//",$pathTemp)){ $this->$path=$pathTemp; $this->$domain=new Domain($domainTemp."."); $this->$filepath=$pathTemp."/".$domainTemp.".zone"; print $this->$filepath; $this->$tempFilepath=$this->$filepath.".tmp"; print $this->$filepath; ... ... Expected result: ---------------- I create the object $zone=new Zone("mydomain.com","/var/named"); $this->$filepath should be /var/named.mydomain.com.zone $this->$tempFilepath should be /var/named.mydomain.com.zone.tmp Actual result: -------------- both variable metioned above have the same value /var/named.mydomain.com.zone.tmp ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26740&edit=1

« previous php.bugs (#52580) next »