Home » die in php

die in php

Today, We want to share with you die in php.In this post we will show you why do we use exit() in php, hear for exit php message we will give you demo and example for implement.In this post, we will learn about Laravel dd And Dump – dd() vs var_dump() vs print_r() with an example.

php die echo & exit()

In this tutorial we learn to all about die in php Examples like as a die, echo & exit() or many more.

Read Also:  Vue JS Lightweight Trumbowyg WYSIWYG editor component

What is difference between die(); and exit(); in PHP?

in php, die() and exit() both are same both useful function are used to debug output the some debug the Error message as well as stop the php script.

PHP die() Function

<?php
$blogspot = "https://www.pakainfo.com/";
fopen($blogspot,"r")
or die("Unable to connect to $blogspot");
?>

die() & sleep() functions

<?php 
$blogspot = ""; 

// open url else die (exit) 
fopen($blogspot, "r") 
or die("Unable to connect to given blogspot."); 
?> 

Using sleep()

<?php 
 
echo date('h:i:s') . "\n"; 

sleep(5); 

echo date('h:i:s'); 
?> 

PHP die() Function Example

<?PHP

$love_latters = fopen(4cgandhi.txt”,”w”);

if(!file_exists("4cgandhi.txt"))
{
	die("File Not Found !!");
}
else
{
	$love_latters("4cgandhi.txt","w");
}

?>

Example Of Die Function

<?php
if(5)
{
	die("True");
}
else
{
	die('False');
}
	echo "It will not execute.";
?>

I hope you get an idea about exit in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Read Also:  VueJS Bar and Star Rating Component and demo

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  AngularJS Remove specific value from array
  2. Read Also:  jQuery Ajax Bootstrap Table Pagination using PHP MySQLi
  3. Read Also:  PHP Laravel AJAX Request GET and POST Example
  4. Read Also:  Laravel 7 Implement Flash Messages with example
  5. Read Also:  SQL SELECT DISTINCT Statement
  6. Read Also:  Vuejs Dropdown Component with example
  7. Read Also:  Angular 6 DataTable Pagination Sorting Searching Example
  8. Read Also:  Remove Last Comma string in javascript
  9. Read Also:  VueJS Bar and Star Rating Component and demo
  10. Read Also:  PHP Laravel AJAX Request GET and POST Example

Leave a Comment

Your email address will not be published. Required fields are marked *