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