[PHP] Finding Out Document That Included Another File
I have a PHP file that gets included by a lot of other files in a lot of other directories. Among other things, this file needs to display a link to that original page. I know I could specify this in a variable in each original file before the INCLUDE statement, but I'd like to do something more elegant and have the INCLUDED file recognize the original file dynamically. Is there some environmental PHP variable that has that info? -- SAMPLE -- Filename: /dummy/BigFile.php ? include ../ImportantFile.php; ? Filename: /ImportantFile.php ? echo $ConstantThatShowsTheFileThatIncludedIt; ? Results: /dummy/BigFile.php Thanks, Jeff Gannaway -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Finding Out Document That Included Another File
The way PHP works currently, $PHPSELF will point to your original file. This is actually a problem, as it means that you cannot use relative includes in the included file if its in a different directory. There's currently discussion on the PHP-DEV list about changing this. Perhaps there's going to a be a new include_local function or, ideally, I'd love it if there was an environment variable set up that pointed to the included page so the script could handle any relative includes (or HTML links, for that matter) itself. For your purposes though, $PHPSELF should work. Hope this helps. Aral :) __ ([EMAIL PROTECTED]) New Media Producer, Kismia, Inc. ([EMAIL PROTECTED]) Adj. Prof., American University ¯¯ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]