tostring_003.phpt 450 B

123456789101112131415161718192021222324252627282930313233
  1. --TEST--
  2. ZE2 __toString() in __destruct/exception
  3. --FILE--
  4. <?php
  5. class Test
  6. {
  7. function __toString()
  8. {
  9. throw new Exception("Damn!");
  10. return "Hello\n";
  11. }
  12. function __destruct()
  13. {
  14. echo $this;
  15. }
  16. }
  17. try
  18. {
  19. $o = new Test;
  20. $o = NULL;
  21. }
  22. catch(Exception $e)
  23. {
  24. var_dump($e->getMessage());
  25. }
  26. ?>
  27. ====DONE====
  28. --EXPECTF--
  29. Fatal error: Method Test::__toString() must not throw an exception, caught Exception: Damn! in %stostring_003.php on line %d