|
exitTerminate the current script with a status code or message Description
never exit(stringint
$status = 0)
Terminates execution of the script.
Shutdown functions
and object destructors
will always be executed even if exit is called.
However,
An exit code of exit is a special function, because it has a dedicated token in the parser, as such it can be used like a statement (i.e. without parentheses) to terminate the script with the default status code. Caution
It is not possible to disable, or create a namespaced function shadowing the global exit function. Parameters
Return ValuesAs this terminates the PHP script, no value is returned. Changelog
ExamplesExample #1 Basic exit example
Example #2 exit example with a string
Example #3 Shutdown functions and destructors run regardless
The above example will output: Shutdown: shutdown() Destruct: Foo::__destruct() Example #4 exit as a statement
NotesWarning
Prior to PHP 8.4.0, exit was a language construct and not a function, therefore it was not possible to call it using variable functions, or named arguments. See Also
|