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()
Contents
In this tutorial we learn to all about die in php Examples like as a die, echo & exit() or many more.
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.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.