Description
The following code:
<?php
spl_autoload_register( function () {
class Autoloaded {}
} );
header_register_callback( function () {
new Autoloaded();
} );
throw new Exception();
Resulted in this output:
PHP Fatal error: Uncaught Error: Class "Autoloaded" not found in /path/to/foo.php:8
Stack trace:
#0 [internal function]: {closure:/path/to/foo.php:7}()
#1 {main}
thrown in /path/to/foo.php on line 8
But I expected this output instead:
Fatal error: Uncaught Exception in /path/to/foo.php:11
Stack trace:
#0 {main}
thrown in /path/to/foo.php on line 11
Seen on Wikipedia servers (T261260) first on PHP 7.4 then 8.1, reported on various other versions. Could reproduce locally on 8.5. Can't reproduce it on 3v4l.org for some reason.
PHP Version
PHP 8.5.0 (cli) (built: Nov 20 2025 19:23:30) (NTS)
Copyright (c) The PHP Group
Built by Debian
Zend Engine v4.5.0, Copyright (c) Zend Technologies
with Zend OPcache v8.5.0, Copyright (c), by Zend Technologies
Operating System
Ubuntu 24.04