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 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,545
    Thumbs Up/Down
    Received: 474/1
    Given: 27/1
    Thanks
    13
    Thanked 197 Times in 181 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: 2149
    Last post by vishwa, 02-07-2018, 01:00 PM
  2. bazzjazz
    bazzjazz
    Replies: 10 | Views: 1255
    Last post by bazzjazz, 03-01-2018, 09:25 AM
  3. UploadCloud
    UploadCloud
    Replies: 2 | Views: 582
    Last post by UploadCloud, 02-06-2018, 03:41 PM
  4. DanielN
    DanielN
    Replies: 4 | Views: 1285
    Last post by DanielN, 03-01-2018, 07:09 AM
  5. Ridew
    Ridew
    Replies: 6 | Views: 1523
    Last post by Ridew, 10-06-2018, 09:44 AM

Older Threads

  1. kevaton
    SIG
    Replies: 11 | Views: 850
    Last post by SIG, 02-08-2018, 08:57 AM
  2. Netman82
    bijutoha
    Replies: 4 | Views: 534
    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: 1462
    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: 648
    Last post by radwebhosting, 02-06-2018, 02:25 AM

Latest Threads

  1. paritosh
    paritosh
    Replies: 0 | Views: 9
    Last post by paritosh, Yesterday, 11:46 PM
  2. Josephine Alberto
    Hello Friends,
    By Josephine Alberto in forum New Member Introductions
    Rob Whisonant
    Replies: 1 | Views: 20
    Last post by Rob Whisonant, Yesterday, 06:17 PM
  3. gracadedues
    gracadedues
    Replies: 0 | Views: 30
    Last post by gracadedues, 11-13-2018, 05:29 PM
  4. swati98760
    swati98760
    Replies: 0 | Views: 48
    Last post by swati98760, 11-12-2018, 11:08 AM
  5. sincharde
    gracadedues
    Replies: 1 | Views: 32
    Last post by gracadedues, 11-13-2018, 03:01 PM

Similar Threads

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