Re: Problem with include PHP 4.3.0

From: Date: Tue, 04 Feb 2003 15:28:20 +0000
Subject: Re: Problem with include PHP 4.3.0
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-134278@lists.php.net to get a copy of this message
Goetz Lohmann wrote :
wich means that "testinclude.php" includes "inc/inc1.php" and "inc/inc1.php" includes "inc/inc2.php" ?
Right. I'm sorry, I didn't modify testinclude.php as you suggested, but inc1.php. With a modified testinclude.php: <? include ('./inc/inc1.php'); ?> I get: Failed opening './inc/inc1.php' for inclusion \ (include_path='.:..:/usr/local/php-4.3.0/lib/php') Seems it doesn't like './' ("inc/inc1.php" is OK). I think that since the name begins with '.', PHP tries to find a file in the working dir, which is null (see below).
insert something like into inc1.php and inc2.php: <?php echo "inc included<br>\n"; echo "<br>\n"; $folder=dir('inc'); // print out folder "inc" while($datei = $folder->read()) {
      echo "$datei<br>\n";
} $folder->close(); echo "<br>\n"; ?>
Unfortunately, this gives nothing. I guess this is because pathnames of files are relative to the working dir. There are only two variables, PATH and TZ in the environment of my Apache server, but nothing about a working dir: cwd() returns an empty string, and so does pwd or ls. Relative pathnames of included files are apparently resolved through a special way, unless they begin with '.' or '..'. But this is not clearly described in the documentation, and it's a bit confusing.

« previous php.general (#134278) next »