php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1229 Bug 1109 revisited WRT class and more than one var
Submitted: 1999-03-11 22:57 UTC Modified: 1999-03-13 09:28 UTC
From: btribit at sungard dot com Assigned:
Status: Closed Package: Other
PHP Version: 3.0.7 OS: Linux 2.2.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: btribit at sungard dot com
New email:
PHP Version: OS:

 

 [1999-03-11 22:57 UTC] btribit at sungard dot com
<HTML>
<PRE>
<?php
class test {
        var $va;
        var $vb;
                
        function init() {
                $this->$va = 0;
                $this->$vb = 0;
                echo $this->$va;
                echo $this->$vb;
        }
        function test1() {
                $this->$va = 10;
                $this->$vb = 15;
                print $this->$va;
                print $this->$vb;
        }
        function test2() {
                $this->$va = 15;
                $this->$vb = 10;
                print $this->$va;
                print $this->$vb;
        }
}        
        $testing = new test;
        $testing->init();
        $testing->test1();
        $testing->test2();
?>      
</PRE>
</HTML>

I compilied this as an apache 1.3.4 module with oracle support. php3.ini not relevant, not using it. The only thing I can offer is that php appears that it is having a problem keeping track of more than one variable. This should provide a clue as to what is going on.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-03-13 09:28 UTC] sas
You have to access member variables as $this->name not as $this->$name which causes your overwriting effect.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue Jul 01 04:01:36 2025 UTC