top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

What is the use of die in PHP?

0 votes
754 views
What is the use of die in PHP?
posted Dec 23, 2017 by Jdk

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

0 votes

The die() function prints a message and exits the current script.The die() in PHP is equivalent to exit()

Syntax:

  die(message)

Example

<?php
$site = "https://www.queryhome.com/";
fopen($site,"r")
or die("Unable to connect to $site");
?>
answer Dec 26, 2017 by Madhavi Latha
0 votes

die( ) function is used to display a message and exit the script. It may be used to print alternate message . Instead of showing error it will show the user friendly message.
die( ) function is only used to print string messages .value of variables cannot print with die( ) function

<?php

die("this is Php die example");

//this will print the message
$x="hello test";

die($x)

//this will show blank screen.
?>
answer Aug 14, 2019 by Siddhi Patel
...