Do you have a question? Post it now! No Registration Necessary. Now with pictures!
September 10, 2004, 10:42 pm
rate this thread
"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?
If you mean, how do you find out programmatically what it is, use the
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 @ pobox.com)