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! Link to comment https://forums.phpfreaks.com/topic/107128-is-it-possible-to-exit-the-execution-of-an-included-file/ 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 Link to comment https://forums.phpfreaks.com/topic/107128-is-it-possible-to-exit-the-execution-of-an-included-file/#findComment-549213 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. Link to comment https://forums.phpfreaks.com/topic/107128-is-it-possible-to-exit-the-execution-of-an-included-file/#findComment-549214 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. Link to comment https://forums.phpfreaks.com/topic/107128-is-it-possible-to-exit-the-execution-of-an-included-file/#findComment-549232 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. Link to comment https://forums.phpfreaks.com/topic/107128-is-it-possible-to-exit-the-execution-of-an-included-file/#findComment-549285 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.