|
Posted by Jim Carlock on 02/26/06 02:57
Looking for a way to extract the path from the pfqpn (partially
full qualified path name).
$sThisServer = $_SERVER['HTTP_HOST'];
// returns either aquaticcreationsnc.com or www.aquaticcreationsnc.com
$sThisServer = $_SERVER['SERVER_NAME'];
// returns aquaticcreationsnc.com whether or not the end-user typed
// in the preceding www.
$sThisFilePath = getcwd();
// returns server-side mapping to folder
Specifically, I want the path from the root of the virtual host to the
current folder... and so far I've got this...
function GetThisPath() {
return("http://" . $_SERVER['SERVER_NAME'] . str_replace("index.php", "", $_SERVER['SCRIPT_NAME']));
}
That assumes the filename in the folder equals "index.php".
I could configure it as an optional parameter?
function GetThisPath($sFilename = "index.php") {
return("http://" . $_SERVER['SERVER_NAME'] . str_replace("index.php", "", $_SERVER['SCRIPT_NAME']));
}
I'm sure there are plenty of ways to handle this. I thought
about implode()/explode() to handle unknown filenames,
but perhaps PHP already handles this?
And the subject... is one of the variables better than the other? One
a wrapper to the other? Which one is the wrapper and which one
is the final calling? Anyone know where to find such details? If there's
a link available...
$_SERVER['SCRIPT_NAME'] versus $_SERVER['PHP_SELF']
Thanks much.
Jim Carlock
Post replies to the group.
[Back to original message]
|