<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Quichcheck PATHFINDER.PHP Pfadfinder</title>
<style  type="text/css">
body {padding: 48px; background: #fafafa; color: #303450;}
p    {font: 13px/135% Chicago,Charcoal,Verdana,Arial,Helvetica,sans-serif;}
pre  {font: 13px/135% "MS Gothic","Andale Mono","Courier New",Courier,monospace; margin-top: 24px;}
a         {color: #cc3300; text-decoration: none;}
a:link    {color: #cc3300; text-decoration: none;}
a:visited {color: #b83000;}
a:active  {color: #dc293f;}
a:hover   {color: #fff; background: #cc3300;}

</style>
</head>
<body>
<?
echo isset($indexGruss)? $indexGruss '<p>Ein Gruß aus der Pathfinder.php. Check was passiert, wenn der pathfinder inkludiert wird: <a href="index.php">auf zur INDEX</a>.</p><pre>';
echo 
"Die Angelegenheit mit der Variable \$_SERVER[PHP_SELF]:\n";

$getDir $_SERVER[PHP_SELF];
$actDirArr = (explode('.php',$getDir));
$actDirArr explode('/',$actDirArr[0]);
$actDir array_pop($actDirArr);
$actDir array_pop($actDirArr);
$actDir file_exists('root')? 'root' $actDir;
echo 
"\n\$actDir: $actDir\n";

switch(
$actDir){
 case 
root:
  
$pathAdmin "admin/";
  
$pathRoot "";
  
$pathTemplates "templates/";
 break;
 case 
admin:
  
$pathAdmin "";
  
$pathRoot "../";
  
$pathTemplates "../templates/";
 break;
 case 
templates:
  
$pathAdmin "../admin";
  
$pathRoot "../";
  
$pathTemplates "";
 break;
}

echo 
"<a href=\"{$pathRoot}pathfinder.php\">Pfadfinder zum Root</a>\n<a href=\"{$pathAdmin}pathfinder.php\">Pfadfinder zum Ordner Admin</a>\n<a href=\"{$pathTemplates}pathfinder.php\">Pfadfinder zum Ordner Templates</a>\n";

echo 
"
==============================================================================
Die Angelegenheit mit der Variable &#95;&#95;FILE&#95;&#95;:
"
;

$actDir __FILE__;
$actDirArr explode('/',$actDir);
array_pop($actDirArr);
$actDir array_pop($actDirArr);
$actDir file_exists('root')? 'root' $actDir;
echo 
"\n\$actDir: $actDir\n";

switch(
$actDir){
 case 
root:
  
$pathAdmin "admin/";
  
$pathRoot "";
  
$pathTemplates "templates/";
 break;
 case 
admin:
  
$pathAdmin "";
  
$pathRoot "../";
  
$pathTemplates "../templates/";
 break;
 case 
templates:
  
$pathAdmin "../admin";
  
$pathRoot "../";
  
$pathTemplates "";
 break;
}

echo 
"<a href=\"{$pathRoot}pathfinder.php\">Pfadfinder zum Root</a>\n<a href=\"{$pathAdmin}pathfinder.php\">Pfadfinder zum Ordner Admin</a>\n<a href=\"{$pathTemplates}pathfinder.php\">Pfadfinder zum Ordner Templates</a>\n";
echo 
"\n==============================================================================\n"


?>
</pre>
<p>Quelltext: <a href="pathfinder.phps">pathfinder.phps</a> &#8501; zurück zum Blog: <a href="http://blog.templaterie.de/476/php-wo-bin-ich-wo-will-ich-hin-pfade-switchen/">PHP: Wo bin ich, wo will ich hin – Pfade Switchen</a></p>
</body>
</html>