PHP Die Function: Usage & Examples
The die function is used to end the script’s execution and output a message. Its syntax is as follows:
die(string $message)
The parameter $message is optional and is used to specify the message to be displayed. If the $message parameter is not provided, an empty string will be output.
For example,
die("Sorry, an error occurred."); // 输出消息并终止脚本执行
die(); // 终止脚本执行,不输出消息
Please note that the die function functions similarly to the exit function, as they are both used to terminate script execution. However, the exit function does not have the functionality to output a message.