Home > Article > Backend Development > Master the solution of die() function in PHP
Generally during the debugging process, we often use the exit()
function, die()
This function is still used relatively rarely Yes, in fact, the PHP
official manual also states that the die()
function is equivalent to the exit()
function. This article will take you to take a look.
First let’s take a look at the syntax of the possible exit()
function
die($message)
$message: can be returned by a program Value, a string, you can also enter no parameters
Return value: If $message is a string, the function will output the string before exiting. $message is an integer and this parameter will not be output. 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 successfully terminate the program
1. The parameter is an integer (generally use the exit()
function )
echo "php.cn"; exit(0);
2. The parameter is a string
$fp=fopen("./ok.txt","r") or die("不能打开该文件");
if the file fails to be opened
输出:不能打开该文件
Recommendation: 《2021 PHP interview questions summary (collection)》《php video tutorial》
The above is the detailed content of Master the solution of die() function in PHP. For more information, please follow other related articles on the PHP Chinese website!