The die function in php is used to output a message and exit the current script. Its usage is as follows: [die(“unable to connect to xxx”)].
The operating environment of this article: windows10 system, php 7.3, thinkpad t480 computer.
die() function outputs a message and exits the current script.
Function syntax:
die(message)
The message parameter is required and specifies the message or status number to be written before exiting the script. Status numbers are not written to the output.
A simple example:
<?php $site = "//m.sbmmt.com/"; fopen($site,"r") or die("Unable to connect to $site"); ?>
Related video sharing: Programming video
The above is the detailed content of How to use die function in php. For more information, please follow other related articles on the PHP Chinese website!