exit() function in PHP

PHPProgrammingServer Side Programming

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!
raja
Published on 04-Dec-2018 10:20:52
Advertisements