Re: climb up the path

From: Date: Fri, 20 Jun 2008 06:22:48 +0000
Subject: Re: climb up the path
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-275669@lists.php.net to get a copy of this message
Richard Heyes wrote:
i need a way to get the path to the parent folder of the folder i am in. one "dirty" way i found is this - require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR .
             ".."              . DIRECTORY_SEPARATOR .
             "config.php");
i can also explode() and reassemble all folders except the last, but this looks also dirty... is there a direct way?
There's nothing dirty about dirname(), and for your issue, just call it twice: dirname(dirname(__FILE__));
I called "dirty" the ".." in my example. Yes, dirname(dirname(__FILE__)); is the way to go - I was just too brainwashed and did not think I can apply it to a directory, too. Thanks, Iv

« previous php.general (#275669) next »