Reputation: 13298
I know it sounds a bit hacky but is there a way of stopping the execution of an included script in php ? Giving this example here
Is there a function or a tiny trick to use to have this effect here ?
note 1 : I know b.php
in the example has a closed conditional structure but if there is code after that structure It will get executed.
note 2 : exit will stop the whole php running execution, that is not what I need.
Upvotes: 1
Views: 1020
Reputation: 782148
You can use a return
statement in the included file to return to the file that includes it.
From the documentation of include
:
It is possible to execute a return statement inside an included file in order to terminate processing in that file and return to the script which called it.
Upvotes: 10