Die And Exit As Functions

Die and Exit used to be language constructs, a special kind of PHP instructions. As such, they had special abilities and behaviors: in particular, it meant that they could not be called dynamically, with their name in a string. Since PHP 8.4, this is possible.

PHP code

<?php

     //Uncaught Error: Call to undefined function \exit()
    $s = 'exit';
    $s('Exit');

?>

Before

PHP Fatal error:  Uncaught Error: Call to undefined function exit()

After

Exit

PHP version change

This behavior changed in 8.4

See Also

Error Messages