Jump to content

[SOLVED] finding the name of the current page


didgydont

Recommended Posts

straight from the manual

http://us2.php.net/manual/en/reserved.variables.server.php

 

echo "

" .$_SERVER['REMOTE_HOST'] ." REMOTE_HOST ";

echo "

" .$_SERVER['REMOTE_PORT'] ." REMOTE_PORT ";

echo "

" .$_SERVER['SCRIPT_FILENAME'] ." SCRIPT_FILENAME ";

echo "

" .$_SERVER['SERVER_ADMIN'] ." SERVER_ADMIN ";

echo "

" .$_SERVER['SERVER_PORT'] ." SERVER_PORT ";

echo "

" .$_SERVER['SERVER_SIGNATURE'] ." SERVER_SIGNATURE ";

echo "

" .$_SERVER['PATH_TRANSLATED'] ." PATH_TRANSLATED ";

echo "

" .$_SERVER['SCRIPT_NAME'] ." SCRIPT_NAME ";

echo "

" .$_SERVER['REQUEST_URI'] ." REQUEST_URI ";

<? $filename = $_SERVER['PHP_SELF'];?>
                                <br><br>the url is :<? echo $_SERVER['HTTP_HOST']; ?>
                                <br> the page is : <? echo $filename;
                                if (strpos($filename, 'index.php') !== FALSE) {echo "you are at index.php";}
                                echo "<br><br>Filename is: " . $_SERVER['SCRIPT_FILENAME'] . "<br>" . $_SERVER['SCRIPT_NAME'] ;?>

 

what about this

$filesn = str_replace('/demo/','',$_SERVER['PHP_SELF']);
                                echo "<br>final: $filesn";

is it possible to do a wild card like '%/' i know that doesnt work but just trying to show you what im trying to do.

  • 2 weeks later...

<?

this solved my problem

$Filepath = $_SERVER['PHP_SELF'];
$Filepath = preg_split('/\//', $Filepath, -1, PREG_SPLIT_NO_EMPTY);
$countarray = count($Filepath);
$countarray = ($countarray-1);
foreach ($Filepath as $key => $fileloc) {
  if ($countarray==$key){echo "$fileloc";}
}

 

 

?>

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.