Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts

    Help with exit()

    I know that exit() exits the script. However, does it only exit out of the current script, or does it null all scripts after it written in the file? Because sometimes I use it to get out of a script if there's an error, and it works fine, but other times it messes the script up.

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Joseph Witchard View Post
    I know that exit() exits the script. However, does it only exit out of the current script, or does it null all scripts after it written in the file? Because sometimes I use it to get out of a script if there's an error, and it works fine, but other times it messes the script up.
    have effect only in the current page and anything after a exit is ignored.
    a detailed explanation for included pages.

    t1.php:
    PHP Code:
    <?php
    exit("ok, I'm gone");
    ?>
    t0.php:
    PHP Code:
    <?php
    include("t1.php");
    echo 
    "I'm here?";
    ?>
    this work in the same way as:
    PHP Code:
    <?php
    exit("ok, I'm gone");
    echo 
    "I'm here?";
    ?>
    best regards

  • The Following 2 Users Say Thank You to oesxyl For This Useful Post:

    FWDrew (12-06-2008), Joseph Witchard (12-06-2008)

  • #3
    Regular Coder
    Join Date
    Oct 2008
    Posts
    255
    Thanks
    113
    Thanked 0 Times in 0 Posts
    Thanks!

  • #4
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by Joseph Witchard View Post
    Thanks!
    you are welcome,
    the best way to deal with messed code is:
    - to have error/warning message turning on
    - don't assume that will be ok, check and implement solution for that problem( this is the only place where paranoia is a good thing, )
    When something go wrong fix the code because anything you left behind will create new problems later.

    best regards

  • Users who have thanked oesxyl for this post:

    Joseph Witchard (12-12-2008)


  •  

    Posting Permissions

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