I'm trying to write an include that needs to 'know' where it's being called from. In the case of nested includes, we want the original parent. For example, if the include in question is i1.php and it is included in a file called i2.php, which is in turn included by parent.php, we need to find parent.php, not i2.php.
Does $_SERVER['REQUEST_URI'] do this reliably? This is a security question; we need it to be foolproof. My understanding is that REQUEST_URI will always return the full path from the server's root directory of the file that was accessed by an end user. Is this correct? Online documentation I've found via Google is somewhat inconclusive.
No, it won't point to a PHP file reliably. The REQUEST_URI item in the $_SERVER array only contains the URI of the request, which needn't necessarily point to any individual file. An example of this would be the "SE Friendly" URLs here on TalkPHP (e.g. http://www.talkphp.com/general/2511-_server-request_uri-question.html) which don't point to an HTML file at all.