top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

What is the use of die in PHP?

0 votes
39 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 by Siddhi Patel
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...