You are here: $_SERVER['SCRIPT_NAME'] versus $_SERVER['PHP_SELF'] (or other?) « PHP Programming Language « IT news, forums, messages
$_SERVER['SCRIPT_NAME'] versus $_SERVER['PHP_SELF'] (or other?)

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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация