While Jacques1 handed you a technique to identify the currently requested parent script in a web server environment, your code reveals some things you are doing that could be better handled explicit with a better architecture pattern. There are many out there, but the most typically use are front-controller/mvc.
For example, if you had a front controller script, you would already know where you were in the control structure all the time, and that state could be passed into the menu.
It is also much better to obfuscate your underlying architecture for SEO purposes, not to mention the fact it lessens what others know about your hosting environment.
Google likes this:
Much better than yoursite.com/fly-control.php
Your site is easier to maintain as well if you are using a front controller that all requests are going through. With the proliferation of small easy to use micro frameworks like slim, silex, lumen etc. or even symfony3 configured as a microkernel, the answer to your question could be very different if you improved your underlying site architecture.
For reference: http://symfony.com/b...-microframework
- dpuk44 likes this