Webmaster Sun Login
Not a member yet? Sign up

Die() Equivalent To Echo Error & Exit() ?

  • HOME
  • FORUMS
  • BLOGS
  • MARKETPLACE
  • ADVERTISING
  • SPECIAL OFFERS
  • WEB HOSTING
  • QUICK MENU
  • REGISTER HERE - Join us for FREE
Results 1 to 4 of 4
    Stick this thread
  1. #1
    Join Date
    Jun 2017
    Posts
    71
    Thumbs Up/Down
    Received: 0/0
    Given: 22/0
    Thanks
    13
    Thanked 1 Time in 1 Post

    Question Die() Equivalent To Echo Error & Exit() ?

    Php Folks,

    Reading this link, did I understand correctly that you use exit() to halt the script and die() to halt the script after spitting out an error mssg on screen ?

    https://stackoverflow.com/questions/1795025/what-are-the-differences-in-die-and-exit-in-php

    So, the following 1 is equivalent to 2 ?

    1.
    PHP Code:
    if(!1==2) {
    echo 
    "no match";
    exit;

    2.
    PHP Code:
    if(!1==2) die("no match"); 
    Latter seems shortest if you want to halt the script after giving an error. And so, best to use that. Right ?
    And, if you don't want to give error then just use like this. Right ?

    PHP Code:
    if(!1==2) {
    exit;

    The above were rush rough examples.

  2. #2
    Join Date
    May 2016
    Location
    USA
    Posts
    1,286
    Thumbs Up/Down
    Received: 406/0
    Given: 27/0
    Thanks
    12
    Thanked 168 Times in 152 Posts
    Never really looked at the difference of die and exit. Personally I have always used them this way.

    exit - when I exit a script prematurely for a a reason that was not an internal error. Like when a page was called and not all POST variables have been sent.

    die - when something went terribly wrong. Like a connection to a mysql database failed.

  3. The Following User Says Thank You to Rob Whisonant For This Useful Post:
    sunny_pro (02-11-2018)

  4. #3
    Join Date
    Jan 2018
    Posts
    3
    Thumbs Up/Down
    Received: 0/0
    Given: 0/0
    Thanks
    0
    Thanked 0 Times in 0 Posts
    yes die() and echo error then exit() both gives the same result.

    in die function after validating condition as per the given parameter die() is triggered which explicitly stops the process. and in exit function we prints the definiteness error message and exites from the run-time program.

  5. #4
    Join Date
    Jun 2017
    Posts
    71
    Thumbs Up/Down
    Received: 0/0
    Given: 22/0
    Thanks
    13
    Thanked 1 Time in 1 Post
    Quote Originally Posted by Sankalppatil View Post
    yes die() and echo error then exit() both gives the same result.

    in die function after validating condition as per the given parameter die() is triggered which explicitly stops the process. and in exit function we prints the definiteness error message and exites from the run-time program.
    You said things the wrong way round. Lol! Double check what you said.

Newer Threads

  1. vishwa
    vishwa
    Replies: 4 | Views: 185
    Last post by vishwa, 02-07-2018, 01:00 PM
  2. bazzjazz
    Hostens
    Replies: 8 | Views: 190
    Last post by Hostens, 02-08-2018, 08:44 AM
  3. UploadCloud
    UploadCloud
    Replies: 2 | Views: 160
    Last post by UploadCloud, 02-06-2018, 03:41 PM
  4. DanielN
    DanielN
    Replies: 2 | Views: 185
    Last post by DanielN, 02-06-2018, 03:50 PM
  5. Ridew
    Ridew
    Replies: 2 | Views: 134
    Last post by Ridew, 02-06-2018, 08:18 PM

Older Threads

  1. kevaton
    SIG
    Replies: 11 | Views: 299
    Last post by SIG, 02-08-2018, 08:57 AM
  2. Netman82
    Mike001
    Replies: 3 | Views: 130
    Last post by Mike001, 02-17-2018, 04:31 PM
  3. vishwa
    Selling Selling imbloggingtips.com
    By vishwa in forum Domains
    vishwa
    Replies: 0 | Views: 124
    Last post by vishwa, 02-02-2018, 04:33 PM
  4. LeatherCrafting
    Web Hosting Company Partner
    By LeatherCrafting in forum Business Partners
    radwebhosting
    Replies: 1 | Views: 126
    Last post by radwebhosting, 02-06-2018, 02:25 AM

Latest Threads

  1. tecxp06
    bijutoha
    Replies: 5 | Views: 77
    Last post by bijutoha, Yesterday, 03:04 AM
  2. sunny_pro
    sunny_pro
    Replies: 0 | Views: 58
    Last post by sunny_pro, 02-16-2018, 02:44 PM
  3. nortoncomsetup
    paul1129
    Replies: 2 | Views: 94
    Last post by paul1129, 02-17-2018, 03:37 AM
  4. Hometutor
    Hometutor
    Replies: 2 | Views: 196
    Last post by Hometutor, 02-14-2018, 03:43 AM
  5. Andyit
    Hometutor
    Replies: 6 | Views: 168
    Last post by Hometutor, 02-13-2018, 05:16 PM

Similar Threads

  1. sunny_pro
    Ridew
    Replies: 6 | Views: 151
    Last post by Ridew, 02-01-2018, 03:42 PM
  2. Nemanja
    Mike001
    Replies: 3 | Views: 231
    Last post by Mike001, 08-13-2017, 07:25 PM
  3. George Lucas
    SEOPub
    Replies: 5 | Views: 996
    Last post by SEOPub, 09-17-2016, 02:38 PM
  4. The Atlantic
    Ron Killian
    Replies: 2 | Views: 935
    Last post by Ron Killian, 01-02-2016, 04:33 AM
  5. sephiroth2407
    sephiroth2407
    Replies: 0 | Views: 1302
    Last post by sephiroth2407, 05-11-2014, 08:30 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Internet Marketing Forum

Webmaster Sun is a forum where you’ll find in-depth discussions and resources to help you succeed on the web whether you are new or experienced. You’ll find it all here. With topics ranging from internet marketing, search engine optimization, social networking, make money online, web hosting, affiliate marketing as well as hands-on technical support for web design, programming and more. We are a growing community of like-minded people that is keen to help and support each other with ambitions and online endeavors. Learn and grow, make friends and contacts for life.

Come Hang Out With Us

    Facebook Twitter Webmaster Forum Google+

    Webmaster Sun Logo
Copyright ©2012 - 2018, WebmasterSun.com. All rights reserved. Internet marketing forum for internet marketers, webmasters, web hosting providers, designers and affiliate marketers.

Welcome to Webmaster Sun

The World's Number 1 Webmaster Community, SEO and Marketplace

Log in!

Continue with Facebook
Continue With Email. By signing up you indicate that you have read and agree to the Terms of Service and Privacy Policy.

Sign in Manually

Need an account? Sign up now!