Jump to content

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";}
}

 

 

?>

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.