PHP die() Function
Definition and Usage
The die() function outputs a message and exits the current script.
This function is exit() Alias of the function.
Syntax
die(status)
Parameters | Description |
---|---|
status | Required. Specifies the message or status number to be written before exiting the script. The status number will not be written to the output. |
Description
If status If it is a string, the function will output the string before exiting.
If status If it is an integer, this value will be used as the exit status. The exit status values are 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.
Tips and Comments
Note:If the PHP version number is greater than or equal to 4.2.0, then in status If the parameter is an integer, it will not output the parameter.
Example
<?php $site = "http://www.codew3c.com/"; fopen($site,"r") or die("Unable to connect to $site"); ?>