035.phpt 670 B

123456789101112131415161718192021222324252627282930313233343536
  1. --TEST--
  2. ZE2: set_exception_handler()
  3. --FILE--
  4. <?php
  5. class MyException extends Exception {
  6. function __construct($_error) {
  7. $this->error = $_error;
  8. }
  9. function getException()
  10. {
  11. return $this->error;
  12. }
  13. }
  14. function ThrowException()
  15. {
  16. throw new MyException("'This is an exception!'");
  17. }
  18. try {
  19. } catch (MyException $exception) {
  20. print "There shouldn't be an exception: " . $exception->getException();
  21. print "\n";
  22. }
  23. try {
  24. ThrowException();
  25. } catch (MyException $exception) {
  26. print "There was an exception: " . $exception->getException();
  27. print "\n";
  28. }
  29. ?>
  30. --EXPECT--
  31. There was an exception: 'This is an exception!'