PHP 4, PHP 5, PHP 7, PHP 8
exit - Output a message and terminate the current script
Code Examples

exit( [string$status] ): void
voidexit intstatus



If status is a string, this function prints the status just before exiting.

If status is an int, that value will be used as the exit status and not printed. Exit statuses should be in the range 0 to 254, the exit status 255 is reserved by PHP and shall not be used. The status 0 is used to terminate the program successfully.

Return Values

No value is returned.



Because this is a language construct and not a function, it cannot be called using variable functions, or named arguments.


This language construct is equivalent to die.

Related Functions

Example of exit

Show all examples for exit

PHP Version:

Function exit:

Miscellaneous Functions Functions

Most used PHP functions