All pastes #343397 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-02-07 00:39 UTC
rendered paste body
<?php

class A {
        var $z;
        var $b1;
        var $b2;
        function A($z) {
                $this->z=&$z;
                $this->b1=new B(1,$this->z);
        }

        function run() {
                echo "A: \$this->z: ",$this->z,"\n";
                $this->b1->run();
                $this->b2=new B(2,$this->z);
                $this->b2->run();
        }

        function set($v) {
                $this->z=$v;
        }
}

class B {
        var $z;
        var $c;
        function B($c,$z) {
                $this->z=&$z;
                $this->c=$c;
        }

        function run() {
                echo "B",$this->c,": \$this->z: ",$this->z,"\n";
        }
}

echo "<pre>";
$a=new A("test");
$a->run();
$a->set("12");
$a->run();

?>