p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

beginning_php thread: chdir()


Message #1 by "Randy Bartels" <bunchofpixels@a...> on Sun, 8 Jul 2001 19:30:28
I read the chapter on file handling.  I came across the chdir() function.  

The reference says it changes PHP's current directory to the specified 

directory.  What exactly is PHP's current directory?  In the examples, I 

just don't see why it is used.
Message #2 by Paul Agin <pagin@k...> on Mon, 09 Jul 2001 12:15:24 -0400
Randy Bartels wrote:



> I read the chapter on file handling.  I came across the chdir() function.

> The reference says it changes PHP's current directory to the specified

> directory.  What exactly is PHP's current directory?  In the examples, I

> just don't see why it is used.



Look at the bottom of page 326. " Your present working directory (PWD) is the

directory that your script happens to be in. Directory changes can be relative to

the PWD or an absolute path from the root directory.



Message #3 by BunchOfPixels@a... on Tue, 10 Jul 2001 12:48:35 EDT

i don't see that on that page.  all i see is an explaination of the fopen 

function.  anyway, how do i find the current working directory?



Message #4 by Paul <pagin@k...> on Tue, 10 Jul 2001 16:22:28 -0400
Actually, I think you want "getcwd()".



$curdir = getcwd();

echo $curdir;





Message #5 by Paul <pagin@k...> on Tue, 10 Jul 2001 16:12:20 -0400
BunchOfPixels@a... wrote:



> i don't see that on that page.  all i see is an explaination of the fopen

> function.  anyway, how do i find the current working directory?



Here's one way to do it:



echo "The current working directory is <b>$HTTP_REFERER</b>";








  Return to Index