note 27897 added to function.dirname
| From: | djphillips at sbcglobal dot net | Date: | Mon, 23 Dec 2002 20:51:20 +0000 |
| Subject: | note 27897 added to function.dirname | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41234@lists.php.net to get a copy of this message | ||
If you need to print a URI i.e. /~yourdir/files instead of an absolute path i.e.
/home/apache/htdocs/~yourdir/files I use the following code:
<?
$self = $PHP_SELF; //Translates as /~yourdir/files/file.php
$filename = strrchr("$self", "/"); //Returns /file.php
$uri = str_replace("$filename","","$self"); //Searches self and
echo "$uri"; //Returns the current URI
?>
feel free to email me if needed.
--
http://www.php.net/manual/en/function.dirname.php
http://master.php.net/manage/user-notes.php?action=edit+27897
http://master.php.net/manage/user-notes.php?action=delete+27897
http://master.php.net/manage/user-notes.php?action=reject+27897