The best way is just to have an "if" statement in your included file. I always use require_once as that stops the script if the file does not exist
main_script.php
echo "Start functions"; require_once('element.php'); echo "After element was loaded";
element.php
echo "Inside Element"; if(!isset($unsetVariable)){ echo "Killed the script"; exit(); } echo "Did not exit inside element";
The above will echo: Start functions Inside Element Killed the script
So if the above is what you want to do without killing the whole script but just exit out of the included file, then use below to do so:
main_script.php
echo "Start functions"; require_once('element.php'); echo "After element was loaded";
element.php
echo "Inside Element"; if(!isset($unsetVariable)){ echo "Killed the script"; }else{ echo "Did not exit inside element"; }
By PHPin24 @ 2009-07-16 15:48:12
|