030.phpt 627 B

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. Overriding $this in catch and checking the object properties later.
  3. --FILE--
  4. <?php
  5. class foo {
  6. public $test = 0;
  7. private $test_2 = 1;
  8. protected $test_3 = 2;
  9. public function bar() {
  10. try {
  11. throw new Exception('foo');
  12. } catch (Exception $this) {
  13. var_dump($this);
  14. }
  15. $this->baz();
  16. }
  17. public function baz() {
  18. foreach ($this as $k => $v) {
  19. printf("'%s' => '%s'\n", $k, $v);
  20. }
  21. print "ok\n";
  22. }
  23. }
  24. $test = new foo;
  25. $test->bar();
  26. ?>
  27. --EXPECTF--
  28. Fatal error: Cannot re-assign $this in %s030.php on line 11