exit()
The function outputs a message and exits the current script. This function is an alias of thedie()
function.
Syntax:
exit ( string $status )
exit ( int $status )
If $status is a string, the function will print $status before exiting .
If $status is an int, the value will be used as the exit status code and will not be printed. Exit status codes should be in the range 0 to 254, and the exit status code 255, which is reserved by PHP, should not be used. Status code 0 is used to terminate the program successfully.
1. If the parameter is a string:
Output: Open file (./exit .html
) failed because the fileexit.html
does not exist in the current path.
2. If the parameter is empty:
Output: exit() is used here
3. Only contains status code
Recommendation:《2021 PHP interview questions summary (collection)》《php video tutorial》
The above is the detailed content of How to use the exit() function in PHP. For more information, please follow other related articles on the PHP Chinese website!