No Rewrite For Exit¶
<?php
namespace A;
use function foo as exit;
function foo() {
print "FOO!
";
exit();
}
Since PHP 8.4, exit() is also a function, and may be called as such.
Yet, it is still a PHP keyword, so it cannot be used as a function name: this would allow creating functions with that name in namespaces. On the other hand, it is possible to use that name as a method name.
And it is also not possible to use exit in a use command: that would allow rewriting exit with another function.
See Also¶
No use for exit [Try me]
PHP Error Messages¶
PHP Features¶
Last updated: 14 July 2026