PHP 4.0 Bug #9673: Relative paths in require(), require_once(), include(), include_once()
| From: | vvo at geocities dot com | Date: | Sat, 10 Mar 2001 21:45:48 +0000 |
| Subject: | PHP 4.0 Bug #9673: Relative paths in require(), require_once(), include(), include_once() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-48604@lists.php.net to get a copy of this message | ||
From: vvo@geocities.com
Operating system: RedHat Linux 7.0
PHP version: 4.0.1pl2
PHP Bug Type: Scripting Engine problem
Bug description: Relative paths in require(), require_once(), include(), include_once()
Here is an example of how relative paths are currently resolved with cascading inclusions (command
line is 'php /home/joe/a.php'):
File '/home/joe/a.php':
<?php
# this include works as expected,
# locating '/home/joe/include/b.inc'
include_once( 'include/b.inc' );
?>
File '/home/joe/include/b.inc':
<?php
# this include will assume '/home/joe/c.inc', but
# not '/home/joe/include/c.inc', as one may expect =(
include_once( 'c.inc' );
?>
File '/home/joe/include/c.inc':
<?php
echo 'hello';
?>
The way all four functions [require(), require_once(), include(), include_once()] resolve relative
paths is counter-intuitive and unproductive with large directory structures, because some trickery
is required to fix this problem. Not to mention that it hurts to see a different behavior from
C-preprocessor #include directives.
If you don't believe me, then see comments to the include() function...
--
Edit Bug report at: http://bugs.php.net/?id=9673&edit=1