note 27897 modified in function.dirname by jmcastagnetto

From: Date: Tue, 24 Dec 2002 04:45:47 +0000
Subject: note 27897 modified in function.dirname by jmcastagnetto
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-41240@lists.php.net to get a copy of this message
[Editor's note: a simpler solution would be to use the dirname() function that does exactly what the code below tries to do] 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. --was-- 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

« previous php.notes (#41240) next »