Return to 030.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / tests / lang |
1.1 ! misho 1: --TEST-- ! 2: $this in constructor test ! 3: --FILE-- ! 4: <?php ! 5: class foo { ! 6: function foo($name) { ! 7: $GLOBALS['List']= &$this; ! 8: $this->Name = $name; ! 9: $GLOBALS['List']->echoName(); ! 10: } ! 11: ! 12: function echoName() { ! 13: $GLOBALS['names'][]=$this->Name; ! 14: } ! 15: } ! 16: ! 17: function &foo2(&$foo) { ! 18: return $foo; ! 19: } ! 20: ! 21: ! 22: $bar1 =new foo('constructor'); ! 23: $bar1->Name = 'outside'; ! 24: $bar1->echoName(); ! 25: $List->echoName(); ! 26: ! 27: $bar1 =& foo2(new foo('constructor')); ! 28: $bar1->Name = 'outside'; ! 29: $bar1->echoName(); ! 30: ! 31: $List->echoName(); ! 32: ! 33: print ($names==array('constructor','outside','outside','constructor','outside','outside')) ? 'success':'failure'; ! 34: ?> ! 35: --EXPECT-- ! 36: success