Re: guess documentroot

From: Date: Thu, 05 Oct 2006 14:35:04 +0000
Subject: Re: guess documentroot
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-242672@lists.php.net to get a copy of this message
Perfect! got it using the following: /* 1 - remove the query string just in case it contains a '/' in it 2 - like Clive said, substr() and strrpos() 'clean' the path to provide the directories only */ $aPath = str_replace($_REQUEST['QUERY_STRING'], '', $_SERVER['SCRIPT_NAME']); $aPath = substr($aRuta, 0, (strrpos($aRuta, '/') + 1)); Thanks a lot guys :) On 10/5/06, clive <clive@rttc.co.za> wrote:
if we have a script like http://localhost/mydir/myseconddir/index.php is there a way to get that it's runing on /mydir/myseconddir/ use $_SERVER['[PHP_SELF'] or $_SERVER['SCRIPT_NAME'] and then simply use strripos() to get the last forwarsd-slash and substr() to get the value you want. -- Regards, Clive


« previous php.general (#242672) next »