Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I don't completely understand the documentation for the include() function:

"Files for including are first looked in include_path relative to the
current working directory and then in include_path relative to the directory
of current script. E.g. if your include_path is ., current working directory
is /www/, you included include/a.php and there is include "b.php" in that
file, b.php is first looked in /www/ and then in /www/include/. "

How do you know where "the current working directory" is?

Re: include()

Mike wrote:
Quoted text here. Click to load it

If you mean, how do you find out programmatically what it is, use the
getcwd() function.

If you mean, how do you as a programmer know what it should be ahead of
time, it's usually the directory containing the top-level script that's
being executed. (This may not hold true for command-line execution, but
should for web execution.)

So if the web server is loading up A.php, and A.php include()s B.php, in
B.php the working directory is still the location of A.php. (Unless of
course you've used chdir() to change it.)

-- brion vibber (brion @

Re: include()

Quoted text here. Click to load it

It is identified in $_SERVER['SCRIPT_FILENAME']. It is the directory from
which the current top-level script is being run. This directory does not
change when you include() from another directory.

Tony Marston

Site Timeline