...

View Full Version : Help with exit()



Joseph Witchard
12-06-2008, 06:27 AM
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.

oesxyl
12-06-2008, 08:36 AM
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
exit("ok, I'm gone");
?>


t0.php:


<?php
include("t1.php");
echo "I'm here?";
?>


this work in the same way as:


<?php
exit("ok, I'm gone");
echo "I'm here?";
?>


best regards

Joseph Witchard
12-06-2008, 09:19 PM
Thanks!

oesxyl
12-07-2008, 01:45 AM
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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum