How to use the exit() function in PHP

autoload
Release: 2023-03-09 11:08:01
Original
2398 people have browsed it

How to use the exit() function in PHP

exit()The function outputs a message and exits the current script. This function is an alias of thedie()function.

Syntax:

exit ( string $status )
Copy after login
exit ( int $status )
Copy after login
  • 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:

Copy after login

Output: Open file (./exit .html) failed because the fileexit.htmldoes not exist in the current path.

2. If the parameter is empty:

Copy after login

Output: exit() is used here

3. Only contains status code

Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!