xref: /php-src/tests/lang/this_assignment.phpt (revision a555cc0b)
1--TEST--
2Test to catch early assignment of $this
3--FILE--
4<?php
5class first {
6
7   function me() { echo "first"; }
8
9   function who() {
10     global $a,$b;
11     $this->me();
12     $a->me();
13     $b->me();
14     $b = new second();
15     $this->me();
16     $a->me();
17     $b->me();
18   }
19}
20
21class second {
22
23   function who() {
24      global $a,$b;
25      $this->me();
26      $a->me();
27      $b->me();
28   }
29   function me() { echo "second"; }
30}
31
32$a = new first();
33$b = &$a;
34
35$a->who();
36$b->who();
37
38echo "\n";
39?>
40--EXPECT--
41firstfirstfirstfirstsecondsecondsecondsecondsecond
42