skinme!
08-01-2002, 10:23 PM
Say the current page is:
http://mysite.com/somedir/go.php
Is there a constant or function that will return a string / contain the path to the file? (in this case "http://mysite.com/somedir/")
Failing that, how can I get to this result?
firepages
08-02-2002, 02:19 AM
This will print out all the variables that PHP has available run it and you will see your options...
<?
ob_start();
print_r($GLOBALS);
$str = ob_get_contents();
$str=nl2br($str);
ob_end_clean();echo $str;
?>
but I think
echo 'http://'.$HTTP_SERVER_VARS[HTTP_HOST].$HTTP_SERVER_VARS[REQUEST_URI];
will be what you are looking for?
(note 4.02+ & you can do this)
echo 'http://'.$_SERVER[HTTP_HOST].$_SERVER[REQUEST_URI];
skinme!
08-02-2002, 01:17 PM
That was the beginning of what I needed. I then got rid of the file name:
<?php
$fullpath = 'http://'.$HTTP_SERVER_VARS[HTTP_HOST].$HTTP_SERVER_VARS[REQUEST_URI];
$thisfile = basename($fullpath);
$cutoffpos = strpos($fullpath,$thisfile);
$thisdir = substr($fullpath, 0, $cutoffpos);
?>
Say the current file is: http://mysite.com/somedir/go.php
$thisdir will contain http://mysite.com/somedir/.
Thanks.