From:             blue2 at hat dot net
Operating system: Windows XP
PHP version:      5.0.3
PHP Bug Type:     Feature/Change Request
Bug description:  Relative paths in require(), require_once(), include(), 
include_once()

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 bug report at http://bugs.php.net/?id=33099&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=33099&r=trysnapshot4
Try a CVS snapshot (php5.0): 
http://bugs.php.net/fix.php?id=33099&r=trysnapshot50
Try a CVS snapshot (php5.1): 
http://bugs.php.net/fix.php?id=33099&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=33099&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=33099&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=33099&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=33099&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=33099&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=33099&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=33099&r=notwrong
Not enough info:             
http://bugs.php.net/fix.php?id=33099&r=notenoughinfo
Submitted twice:             
http://bugs.php.net/fix.php?id=33099&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=33099&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=33099&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=33099&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=33099&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=33099&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=33099&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=33099&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=33099&r=mysqlcfg

Reply via email to