Webmaster Sun Login
Not a member yet? Sign up

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

  • HOME
  • FORUMS
  • WHAT'S NEW
  • BLOGS
  • MARKETPLACE
  • ADVERTISING
  • SPECIAL OFFERS
  • WEB HOSTING
  • QUICK MENU
  • REGISTER HERE - Join us for FREE
Results 1 to 3 of 3
    Stick this thread
  1. #1
    Join Date
    Jun 2017
    Posts
    86
    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,623
    Thumbs Up/Down
    Received: 493/1
    Given: 27/1
    Thanks
    13
    Thanked 203 Times in 187 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
    Jun 2017
    Posts
    86
    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: 2311
    Last post by vishwa, 02-07-2018, 01:00 PM
  2. bazzjazz
    bazzjazz
    Replies: 10 | Views: 1417
    Last post by bazzjazz, 03-01-2018, 09:25 AM
  3. UploadCloud
    UploadCloud
    Replies: 2 | Views: 701
    Last post by UploadCloud, 02-06-2018, 03:41 PM
  4. DanielN
    DanielN
    Replies: 4 | Views: 1417
    Last post by DanielN, 03-01-2018, 07:09 AM
  5. Ridew
    Ridew
    Replies: 6 | Views: 2007
    Last post by Ridew, 10-06-2018, 09:44 AM

Older Threads

  1. kevaton
    SIG
    Replies: 11 | Views: 933
    Last post by SIG, 02-08-2018, 08:57 AM
  2. Netman82
    bijutoha
    Replies: 4 | Views: 579
    Last post by bijutoha, 02-21-2018, 04:02 AM
  3. vishwa
    Selling Selling imbloggingtips.com
    By vishwa in forum Domains
    vishwa
    Replies: 5 | Views: 1589
    Last post by vishwa, 07-04-2018, 08:47 AM
  4. LeatherCrafting
    Web Hosting Company Partner
    By LeatherCrafting in forum Business Partners
    radwebhosting
    Replies: 1 | Views: 734
    Last post by radwebhosting, 02-06-2018, 02:25 AM

Latest Threads

  1. Fixfast
    Keyword Organic Traffic
    By Fixfast in forum Google
    Rob Whisonant
    Replies: 1 | Views: 12
    Last post by Rob Whisonant, Today, 09:50 PM
  2. Marc van Leeuwen
    Goyum
    Replies: 3 | Views: 121
    Last post by Goyum, 02-13-2019, 07:51 AM
  3. ethelglover
    sarahboyer
    Replies: 10 | Views: 96
    Last post by sarahboyer, Today, 07:05 AM
  4. RyanChapman
    lauratorgerson
    Replies: 10 | Views: 163
    Last post by lauratorgerson, Today, 05:05 AM
  5. ethelglover
    LearnTheNew
    Replies: 5 | Views: 133
    Last post by LearnTheNew, 02-15-2019, 05:16 AM

Similar Threads

  1. sunny_pro
    Ridew
    Replies: 6 | Views: 678
    Last post by Ridew, 02-01-2018, 03:42 PM
  2. Nemanja
    Mike001
    Replies: 3 | Views: 498
    Last post by Mike001, 08-13-2017, 07:25 PM
  3. George Lucas
    SEOPub
    Replies: 5 | Views: 1339
    Last post by SEOPub, 09-17-2016, 02:38 PM
  4. The Atlantic
    Ron Killian
    Replies: 2 | Views: 1166
    Last post by Ron Killian, 01-02-2016, 04:33 AM
  5. sephiroth2407
    sephiroth2407
    Replies: 0 | Views: 1501
    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 - 2019, 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!