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,479
    Thumbs Up/Down
    Received: 452/1
    Given: 27/1
    Thanks
    13
    Thanked 188 Times in 172 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: 1338
    Last post by vishwa, 02-07-2018, 01:00 PM
  2. bazzjazz
    bazzjazz
    Replies: 10 | Views: 1118
    Last post by bazzjazz, 03-01-2018, 09:25 AM
  3. UploadCloud
    UploadCloud
    Replies: 2 | Views: 483
    Last post by UploadCloud, 02-06-2018, 03:41 PM
  4. DanielN
    DanielN
    Replies: 4 | Views: 1178
    Last post by DanielN, 03-01-2018, 07:09 AM
  5. Ridew
    Ridew
    Replies: 2 | Views: 959
    Last post by Ridew, 02-06-2018, 08:18 PM

Older Threads

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

Latest Threads

  1. Virender
    paul1129
    Replies: 1 | Views: 14
    Last post by paul1129, Today, 02:37 PM
  2. macfais
    macfais
    Replies: 0 | Views: 3
    Last post by macfais, Today, 11:18 AM
  3. Digiwolves
    Digiwolves
    Replies: 0 | Views: 13
    Last post by Digiwolves, Today, 08:16 AM
  4. Shumpanting
    Shumpanting
    Replies: 0 | Views: 26
    Last post by Shumpanting, Today, 05:12 AM
  5. Shumpanting
    paul1129
    Replies: 1 | Views: 28
    Last post by paul1129, Today, 02:44 PM

Similar Threads

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