Thanks for you interest cgraz too, I realy can use some help with that one.
If you would ask me, it looks like a shortcomming in the desing of PHP for now. I've reduced the problem a lot just to the basic where it starts.
So this is what I want to have:
A script that can "say" I'm located "here"
OR better said "echo" I'm located in ( "D:\Apache\htdocs\somewhere\echonow.php"
OR "/somewhere/echonow.php") as is relative to the documentroot, virtual directory, or filesystempath.
Any will do.
The first file does simply prints out the path like this:
<?// /htdocs/specials/echonow.php <= watch this path!
echo('script_filename:'.$_SERVER['SCRIPT_FILENAME'].'<br>');
?>
The second file is the "caller" witch may NOT have influence on the CALLED file. (as is not the case now)
<? // htdocs/otherdir/callerfile.php <= watch this path again
include('/specials/echonow.php');
?>
So calling the callerfile.php will output:
script_filename:/otherdir/callerfile.php
But I would like:
script_filename:/specials/echonow.php
OR
script_filename: D:/Apache/htdocs/somewhere/echonow.php
or something that looks like that 🙂
Extra note:
this is the reverse of what I found on the PHP site .... i'll search for it, brb 🙂
OK, here it is: THIS is THE REVERSE of the problem:
murat at nospamx dot robcol dot k12 dot tr
30-Dec-2002 06:15
Another interesting thing about the included files is that they return the includer's file information when you use server variables. For example let's say you have two files like this:
/included.php
<? echo $_SERVER['PHP_SELF']; ?>
/caller.php
<? include "included.php"; ?>
When caller.php is called, PHP will print "/caller.php" although the echo function is actually called from the /included.php file.
This might be very useful when you create a logger script which will log the caller page's relative url, time, etc. to a database every time a page is viewed. You would simply use <? include "logthis.php"; ?> at the beginning of each page you would wish to be logged.
(copied from php.net documentation)