Home  >  Article  >  Backend Development  >  What is the usage of php exit

What is the usage of php exit

藏色散人
藏色散人Original
2021-05-17 09:22:462427browse

php The function of exit is to output a message and exit the current script. The exit function is an alias of the die() function. Its usage syntax is "exit(status)". The status parameter specifies to be written before exiting the script. message or status number.

What is the usage of php exit

The operating environment of this article: Windows7 system, PHP7.1 version, DELL G3 computer

exit() function outputs a message and exits the current script.

This function is an alias of the die() function.

Syntax

exit(status)

Parameters

status Required. Specifies the message or status number to be written before exiting the script. Status numbers are not written to the output.

Description

If status is a string, the function will output the string before exiting.

If status is an integer, this value will be used as the exit status. The exit status value is between 0 and 254. Exit status 255 is reserved by PHP and will not be used. Status 0 is used to terminate the program successfully.

Tips and Notes

Note: If the version number of PHP is greater than or equal to 4.2.0, then when status is an integer, this parameter will not be output.

Example

<?php
$site = "http://www.w3school.com.cn/";
fopen($site,"r")
or exit("Unable to connect to $site");
?>

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of What is the usage of php exit. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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