[nycphp-talk] PHP on Win.: Get Drive Letter for Current Script
Dan Cech
dcech at phpwerx.net
Sun Mar 13 17:31:02 EST 2005
Jayesh Sheth wrote:
> Hi Dan,
>
> Looking at my test script again, there is an important difference between
> getcwd() and __FILE__ that may be of interest of to others.
>
> The sample script is:
> <?php
> echo getcwd();
> echo "\n";
> echo __FILE__;
> ?>
>
> I invoked it with:
> cd c:\php4cli
> php-cli.exe c:\devel\php\getcwd.php
>
> And it outputted:
> C:\PHP4CLI
> c:\devel\php\getcwd.php
>
> So, perhaps getcwd() outputs where you currently are at the command line,
> but __FILE__ outputs the full path (including drive letter) to the
> currently running script.
Indeed, you are correct. In a web environment they are usually the
same, but from the command line or if you use the chdir() function in
your scripts, getcwd could very easily be different.
I wish I could get down to some of the meetings to take up your offer!
Dan
> Best regards,
>
> - Jay
More information about the talk
mailing list