Re: Re: Include wierdness.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Rob Adams wrote:
One correction. The include('lib/test2.php') is actually a require_once('lib/test2.php'). That's why it quits and I don't get the third include.

you 100% sure your include_path is '.' ? just asking. also you mention a /www/lib and a /www/include dir - maybe thats the problem?

maybe you can make the problem go away by setting include_path to
'.:/www/include' or '.:/www/lib'

I must say I think its overkill to use file_exists() on files
you are going to require_once() - although no doubt there is a good
reason to do it sometimes :-)

it is odd though, file_exists() returns true yet the file cannot
be included.

--
any chocolate chips in this cookie jar care to enlighten the crumbs?



-- Rob


"Rob Adams" <rob_adams@xxxxxxxxxxx> wrote in message news:20050304155533.31138.qmail@xxxxxxxxxxxxxxxx


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



-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux