PHP exit() Function
Example
Print a message and exit the current script:
<?php
$site = "https://www.w3schools.com/";
fopen($site,"r")
or exit("Unable to connect to $site");
?>
Definition and Usage
The exit() function prints a message and terminates the current script.
Syntax
exit(message)
Parameter Values
Parameter | Description |
---|---|
message | Required. A message or status number to print before terminating the script. A status number will not be written to the output, just used as the exit status. |
Technical Details
Return Value: | Nothing |
---|---|
PHP Version: | 4+ |
❮ PHP Misc Reference