cgm225 Posted May 24, 2008 Share Posted May 24, 2008 Is it possible to "exit" the action/execution of an included file, but NOT the execution of the file that included it? Restated, if I have: SomeFile.php '--------------included AnotherFile.php Is is possible to exit AnotherFile.php but continue on with executing SomeFile.php Thanks in advance! Quote Link to comment Share on other sites More sharing options...
AndyB Posted May 24, 2008 Share Posted May 24, 2008 not with the exit() function exit — Output a message and terminate the current script Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted May 24, 2008 Share Posted May 24, 2008 no. including a file is essentially the same as copying the contents of the file and pasting it where the include() is. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 24, 2008 Share Posted May 24, 2008 Read this - http://php.net/return If you put a return() in the global scope (main code) in an included file, it will stop execution of the included code and return to the file that included that code. Quote Link to comment Share on other sites More sharing options...
deadonarrival Posted May 25, 2008 Share Posted May 25, 2008 I didn't know return worked in the global scope like that. I was about (so I'll carry on) to suggest making the included file into a function. Then just include it and call the function, and use return to do what you wanted, but if you don't need to make it into a function, that's just taken half the effort away. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.