Computer >> Computer tutorials >  >> Programming >> PHP

exit() function in PHP


The exit() function prints a message and exits the current script.

Syntax

exit(msg)

Parameters

  • msg − The message to write before exiting the script.

Return

The exit() function returns nothing.

Example

<?php
   $url = "https://www.example.com/";
   fopen($url,"r")
   or exit("Can't connect!");
?>

Output

The following is the output.

Can’t connect!