Include wierdness.
| From: | Rob Adams | Date: | Fri, 04 Mar 2005 15:55:57 +0000 |
| Subject: | Include wierdness. | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-209989@lists.php.net to get a copy of this message | ||
From the manual on 'include':
"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/."
I have a file in my root dir (we'll call it /www) that includes the file
/www/lib/test.php as follows:
include('lib/test.php');
test.php looks like this:
<?
echo 'Inside first included file.';
if (file_exists('lib/test2.php'))
echo 'This file exists.';
include('lib/test2.php');
echo 'Ending first included file.';
?>
/www/lib/test2.php exists. Whenever I run this, I get the first two echo
statements, without getting the third one. The error log reports that it
couldn't find lib/test2.php. If I take out the 'lib/' in the include
statement, it works. According to the description from the manual, either
way should work. Has anyone ever come across this problem before, and is
there a config setting that causes it? I'm stumped here, and I refuse to go
change all the code when from what I've read it should already be working.
-- Rob