|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26591 "__autoload threw an exception" during an uncaught Exception
Submitted: 2003-12-11 07:30 UTC Modified: 2003-12-11 13:15 UTC
From: bugzilla at malkusch dot de Assigned:
Status: Closed Package: Class/Object related
PHP Version: 5.0.0b2 (beta2) OS: Debian Woody
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Bug Type:
From: bugzilla at malkusch dot de
New email:
PHP Version: OS:


 [2003-12-11 07:30 UTC] bugzilla at malkusch dot de
If I use __autoload() PHP says "__autoload threw an exception" while I throw an exception which would be caught somewhere between several catch statements.

That means __autoload() first loads the Class for the thrown Exception then PHP searches a catch statement for the threwn  exception. The first statement is for another Exception (the exception still is uncaught) so __autoload should load this class. But here it fails and says "__autoload threw an exception".

A Workaround would be to require all Exceptions for all catch Statements before any exception is thrown.

Reproduce code:
// Be sure that Test1.php and Test2.php exists

function __autoload($className) {
    echo '<br>' . $className;
    require_once ucfirst($className) . '.php';
    echo 'loaded';

// If I would do "require_once Test1.php;" here
// everything would work

try {

    throw new Test2();

} catch(Test1 $e) {

} catch(Test2 $e) {


Expected result:

Actual result:
Fatal error: __autoload threw an exception in /home/malkusch/http/index.php on line 13


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2003-12-11 13:15 UTC]
This bug has been fixed in CVS.

In case this was a PHP problem, snapshots of the sources are packaged
every three hours; this change will be in the next snapshot. You can
grab the snapshot at
In case this was a documentation problem, the fix will show up soon at

In case this was a website problem, the change will show
up on the site and on the mirror sites in short time.
Thank you for the report, and for helping us make PHP better.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon May 27 00:01:31 2024 UTC