#33099 [Opn->Fbk]: Relative paths in require(), require_once(), include(), include_once()
| From: | tony2001@php.net | Date: | Sun, 22 May 2005 11:13:35 +0000 |
| Subject: | #33099 [Opn->Fbk]: Relative paths in require(), require_once(), include(), include_once() | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-79332@lists.php.net to get a copy of this message | ||
ID: 33099
Updated by: tony2001@php.net
Reported By: blue2 at hat dot net
-Status: Open
+Status: Feedback
Bug Type: Feature/Change Request
Operating System: Windows XP
PHP Version: 5.0.3
New Comment:
Please try using this CVS snapshot:
http://snaps.php.net/php5-STABLE-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.0-win32-latest.zip
Previous Comments:
------------------------------------------------------------------------
[2005-05-22 09:47:44] blue2 at hat dot net
Description:
------------
Relative paths in require(), require_once(), include(), include_once()
does not resolve correctly (i.e. relative to the file that reference
the script, not the file that execute the script).
Reproduce code:
---------------
Say, there is the main script 'test.php' and two other files, 'a.inc'
and 'b.inc' (in subdirs):
File './test.php':
<?php
require_once( 'include/a/a.inc' );
?>
File './include/a/a.inc':
<?php
require_once( '../b.inc' );
echo 'a.inc ';
?>
File './include/b.inc':
<?php
echo 'b.inc ';
?>
Running 'test.php' fails.
Expected result:
----------------
When a.inc include "../b.inc", it should reference from the location of
./include/a/a.inc, not the executing file, ./test.php.
This happens on both Windows XP and UNIX (Red Hat Linux), and probably
all other platforms (which I can't verify).
This really hurt modularity.
I know this is not consider a bug, but would you improve this please?
(like adding a realtive_include() function would really be nice)
Actual result:
--------------
Fatal error: main() [function.require]: Failed opening required
'../b.inc' (include_path='.;C:\php5\pear') in XXXXX on line 4
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=33099&edit=1