faqts : Computers : Programming : Languages : PHP : Function Libraries

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

41 of 46 people (89%) answered Yes
Recently 8 of 10 people (80%) answered Yes

Entry

How do you find the current working directory? Why isn't there a 'pwd()' function?

Sep 11th, 2002 12:11
Dan Stockton, Leon Atkinson, Chris Kings-Lynne, http://www.php.net/manual/en/function.getcwd.php


One way you can figure this out is to use the __FILE__ constant.  It 
constains the full path the file being executed.  You can use dirname() 
to chop off the file name.  Try this script:
<?
   print(dirname(__FILE__));
?>
This will be your working directory when your script starts, so if you 
use chdir(), you'll have to track it yourself.
[+ + +]
 .. <?=getcwd()?> will do the same thing, only cheaper