ID: 9673
User Update by: [EMAIL PROTECTED]
Status: Analyzed
Bug Type: Scripting Engine problem
Description: Relative paths in require(), require_once(), include(), include_once()
We are talking about all four functions here, not just include(). The resemblance of
require() to the #include directive, as documented:
<quote>The require() statement replaces itself with the specified file, much like the
C preprocessor's #include works.</quote>
If it's a "known issue", are there any plans to fix it?
Thanks.
Previous Comments:
---------------------------------------------------------------------------
[2001-03-15 09:08:11] [EMAIL PROTECTED]
First, PHP include() is in no way related or was promised to
relate to C preprocessor directives, so no wonder it behaves
differently.
Now, all relative pathes are resolved against the current
directory of the including script (which is the directory
where it's located). This is a known issue. Use
include_pathes in the meantime.
---------------------------------------------------------------------------
[2001-03-10 16:45:48] [EMAIL PROTECTED]
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...
---------------------------------------------------------------------------
Full Bug description available at: http://bugs.php.net/?id=9673
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]