0 0 Votes

PHP: exit in include() should not cancel calling script

Question by Guest | 06/03/2019 at 15:52

I have structured my website in a way that I insert the page content in my index.php depending on the url. I am using the function include() for those includes.

In some of these included files, I also use an exit if I only want to execute the inserted script up to a certain extent.

Now the problem is that after invoking exit, my main page (the index.php) will be aborted, too. As a result, for example, the footer is no longer displayed on the corresponding pages. What can I do?


Stefan Trost

Show Profile | Message
1Best Answer
1 Vote

Just use "return" instead of "exit".

In fact, with exit, the calling parent script is also stopped. With return, only the script that is included.
06/03/2019 at 22:14

ReplyPositive Negative

Related Topics

Abort Windows Batch Script
Question | 1 Answer

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.


Ask your own question or write your own articles on askingbox.com. How to do.