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!

Updated on: 30-Dec-2019

873 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements