NYCPHP Meetup

NYPHP.org

[nycphp-talk] relative paths in Windope

Rob Marscher rmarscher at beaffinitive.com
Mon Sep 25 10:49:13 EDT 2006


realpath() is a handy function too when dealing with relative paths:
http://us2.php.net/manual/en/function.realpath.php

Also, if you like to type less, there's the "magic" constant __FILE__ 
that will give you the full path to the current file:
http://us2.php.net/manual/en/language.constants.predefined.php

I often do this:
realpath(dirname(__FILE__) . '/../../somefile')

-Rob


David Krings wrote:
> At 05:27 PM 9/24/2006, you wrote:
>   
>> Is http://us3.php.net/getcwd what you're looking for?
>>
>> mkdir (getcwd () . "\\directoryname");
>>
>> DiRN
>>     
>
> That would work as well. What I did is use this
> dirname($_SERVER['SCRIPT_FILENAME'])
> in the start file and assigned the output to a session variable. It 
> basically gives me the "root" of my entire folder set. This way I can 
> always extend the path if needed. Using getcwd will work fine when I deal 
> only with things that are in my current directory. In the described case, 
> that is so, but I know for sure that I will need the path to point to some 
> place that is down a different tree from the root.
>
> Thanks for the tip.
>
>
> David K. 
>
> _______________________________________________
> New York PHP Community Talk Mailing List
> http://lists.nyphp.org/mailman/listinfo/talk
>
> NYPHPCon 2006 Presentations Online
> http://www.nyphpcon.com
>
> Show Your Participation in New York PHP
> http://www.nyphp.org/show_participation.php
>   




More information about the talk mailing list