tags:

views:

30

answers:

1

hi there,

I have a php script that runs some checks, if the checks fail it includes another file so that it can do its checks, if something in the included file fails then i need to exit out of the included script so that the including script can continue doing its stuff.

is there any way to kill the currently executing script without killing the including script?

+3  A: 

see http://docs.php.net/return:

return
[...]
If called from the global scope, then execution of the current script file is ended. If the current script file was include()ed or require()ed, then control is passed back to the calling file.

VolkerK
This would work. If however the included file has functions / methods (other scope) or other includes (will only return from the 'grandchild'), another possible solution would be to throw an exception which is only catched in the main file.
Wrikken
the other file has no functions that will ever need this, im assuming that an if() is still the same scope though?
Hailwood