this_assignment.phpt 561 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. --TEST--
  2. Test to catch early assignment of $this
  3. --FILE--
  4. <?php
  5. class first {
  6. function me() { echo "first"; }
  7. function who() {
  8. global $a,$b;
  9. $this->me();
  10. $a->me();
  11. $b->me();
  12. $b = new second();
  13. $this->me();
  14. $a->me();
  15. $b->me();
  16. }
  17. }
  18. class second {
  19. function who() {
  20. global $a,$b;
  21. $this->me();
  22. $a->me();
  23. $b->me();
  24. }
  25. function me() { echo "second"; }
  26. }
  27. $a = new first();
  28. $b = &$a;
  29. $a->who();
  30. $b->who();
  31. echo "\n";
  32. ?>
  33. --EXPECT--
  34. firstfirstfirstfirstsecondsecondsecondsecondsecond