Question

Locked

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.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Answers

Collapse -

Hmmm

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.

Back to Web Development Forum
1 total post (Page 1 of 1)  

Related Forums