lucy24 - 10:15 pm on Apr 21, 2013 (gmt 0)
I'm not sure I fully understand your question
"What is the safest and/or most efficient way to detect whether the present file is acting as a document in its own right, or is included in something else?"
The query string exists in any case. If either of the two parameters has gone missing entirely, the page won't get drawn and the 404 page will be shown instead. This is fine if the php file was supposed to be creating a complete page. But if the php file was only supposed to make the navigation footer, the full content of the 404 page would then be shown in the location allocated to the footer.
Now, I don't know if it's physically possible for a server to locate and include a php file but still misplace its parameters-- but I kinda think I ought to code for the possibility.