\|/ $PHP_SELF
| From: | Gerry Figueroa Anadon | Date: | Tue, 20 Nov 2001 05:18:13 +0000 |
| Subject: | \|/ $PHP_SELF | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-75206@lists.php.net to get a copy of this message | ||
Does $PHP_SELF always get's the path of the document it resides in even if the document is an
include?
I'm trying to set one of those breadcrumb path navigation scripts and I don't want to copy
the
script to every directory, I just want to include it in my header.inc.
As a result I only get the home directory link that way.
I tryed using a variable like $string=$PHP_SELF; then in the script I replaced the line:
$str=$PHP_SELF; with $str=$string; , but it turn out as an empty variable.
Here is the original unaltered php:
$site = "http://".$HTTP_HOST."/";
//$site = "http://site.com";
$str=$PHP_SELF;
ereg("^(.+)/.+\\..+$", $str, $part);
$str = $part[1];
$str = substr($str, 1);
$label = array("home"=>"Home",
"anunciate"=>"Anunciate",
"encuentreMedico"=>"Encuentre un Medico",
"anunciateHospital"=>"Anunciate Hospital",
"anunciateMedico"=>"Anunciate Medico",
"article"=>"Article",
"encuentreHospital"=>"Encuentre un Hospital");
if (ereg('/', $str)){
$arr = split("/", $str);
$num = count($arr);
for($i=0; $i < $num; ++$i){
echo(" > <a
href=\"". $site . $arr[$i]
."/\">".$label[$arr[$i]]."</a>");
$site = $site . $arr[$i] ."/";
}
}elseif (ereg("[a-zA-Z_]{1,}$",$str)){
$arr = $str;
echo(" > <a
href=\"http://".$HTTP_HOST."/".$arr."/\">".$label[$arr]."</a>");
}else{
echo("");
}
Thanks:
Gerry Figueroa
Dynamic Intermedia