Re: document root

From: Date: Thu, 30 Nov 2000 20:36:51 +0000
Subject: Re: document root
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-28119@lists.php.net to get a copy of this message
what about function get_rootpath() { $path = '' ; for( $i = 1 ; $i < substr_count( $GLOBALS['HTTP_SERVER_VARS']['PHP_SELF'] , '/' ) ; $i++ ) $path .= '../' ; return $path ; } At 20:24 30.11. 2000, Samuel Luescher wrote the following: -------------------------------------------------------------- >does anybody know about a very sophisticated way to get a (relative) path to >the document root of a site? > >i get it exploding $PHP_SELF into directories, but i think there must be a >smarter way. > >function get_rootpath() { > global $PHP_SELF; > $dirs = explode("/",$PHP_SELF); > $path = ""; > for ($i = 1; $i < sizeof($dirs)-1; $i++) { > $path .= "../"; > } > return $path; >} > > >-- >PHP General Mailing List (http://www.php.net/) >To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net >For additional commands, e-mail: php-general-help@lists.php.net >To contact the list administrators, e-mail: php-list-admin@lists.php.net ------end of quote------ ____________________________________________________________ Cynic: A member of a group of ancient Greek philosophers who taught that virtue constitutes happiness and that self control is the essential part of virtue. cynic@mail.cz ICQ: 2808 2505

« previous php.general (#28119) next »