Web Development



Trying to get a combine Return() and Exit() in PHP

By jvnane ·
I have this search page on a website that searches files names and sub-directories. Every time a file has been searched the search method calls itself again to search the next file. This is happening inside my include file. When it is at the very end of all the files, (also at the end of a long chain of nested functions) I want to return to the page that the include file was called on. The problem is that if I use exit() then the rest of the code on the main page doesn't run. If I use return or just nothing at all then it will try returning to the previous function and just mess everything up. How do I return to this page like using an exit command, but still run the rest of the script on that page.

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -


by Tony Hopkinson In reply to Trying to get a combine R ...

You've misunderstood include

Basically the incude directive in your 'main page' is replaced by the content of tge included file. There is no inside to the include file, it has the same scope as the page. All included does is save you copy and pasting it everywhere you want to use it, and maintining all those copies. It's not a library or dll or some such.

Best bet is to do the paste it in manually into a page and then get it working where you can see it. Then put the working stuff you want to use in the include file.

I have a vague memory of a similar issue and I think all that we did was put all the code in the include file inside a function, bit crap but it worked.

Related Discussions

Related Forums