bug31102.phpt 874 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. --TEST--
  2. Bug #31102 (Exception not handled when thrown inside __autoload())
  3. --FILE--
  4. <?php
  5. $test = 0;
  6. function __autoload($class)
  7. {
  8. global $test;
  9. echo __METHOD__ . "($class,$test)\n";
  10. switch($test)
  11. {
  12. case 1:
  13. eval("class $class { function __construct(){throw new Exception('$class::__construct');}}");
  14. return;
  15. case 2:
  16. eval("class $class { function __construct(){throw new Exception('$class::__construct');}}");
  17. throw new Exception(__METHOD__);
  18. return;
  19. case 3:
  20. return;
  21. }
  22. }
  23. while($test++ < 5)
  24. {
  25. try
  26. {
  27. eval("\$bug = new Test$test();");
  28. }
  29. catch (Exception $e)
  30. {
  31. echo "Caught: " . $e->getMessage() . "\n";
  32. }
  33. }
  34. ?>
  35. ===DONE===
  36. <?php exit(0); ?>
  37. --EXPECTF--
  38. __autoload(Test1,1)
  39. Caught: Test1::__construct
  40. __autoload(Test2,2)
  41. Caught: __autoload
  42. __autoload(Test3,3)
  43. Fatal error: Class 'Test3' not found in %sbug31102.php(%d) : eval()'d code on line 1