|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-11-20 15:58 UTC] krzysztof dot talajko at gmail dot com
Description:
------------
Throw exception in __autoload() implementation is impossible. Instead fatal error "Class (...) not found" is reported.
Reproduce code:
---------------
<?php
function loader($class) {
@include_once($class.'.php');
if (!class_exists($class, false)) {
throw new Exception("Class ".$class." not found");
}
}
spl_autoload_register('loader');
try{
class FooClass extends Some_Not_Existing_Class {}
}
catch (Exception $e) {
echo "Caught load class failed exception (".$e->getMessage().").";
}
Expected result:
----------------
Caught load class failed exception (Class Some_Not_Existing_Class not found).
Actual result:
--------------
Fatal error: Class 'Some_Not_Existing_Class' not found in C:\dev\workspace\foo.php on line 19
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Dec 06 10:00:01 2025 UTC |
Simpler reproduce code is (results same as in original code): <?php function __autoload($class) { throw new Exception("Class ".$class." not found"); } try{ new Foo; } catch (Exception $e) { echo "Caught load class failed exception (".$e->getMessage().")."; }