php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #14638 Allow include() & friends to use relative paths better
Submitted: 2001-12-21 07:32 UTC Modified: 2001-12-21 07:50 UTC
From: jukkaho at mail dot student dot oulu dot fi Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.1.0 OS: All
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: jukkaho at mail dot student dot oulu dot fi
New email:
PHP Version: OS:

 

 [2001-12-21 07:32 UTC] jukkaho at mail dot student dot oulu dot fi
Currently all include()-type functions with relative include paths are relative to file, which is server by webserver ($SCRIPT_NAME).

It would make life a lot easier if include() could be enchanced to accept optional flag parameter (or perhaps it would be better to create new function names to avoid magic-flag -pollution).

And if it's set, include would be done relative to including file (instead of $SCRIPT_NAME).

For example with this ability, following code should work as expected:

index.php (also $SCRIPT_NAME):
<?php include("include/second.php"); ?>

include/second.php:
<?php include("third.php",1); ?>

include/third.php:
<?php echo "Ok."; ?>

This allows much easier code portability where directory trees are different (difficult to play with $DOCUMENT_ROOT).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-21 07:50 UTC] mfischer@php.net
If you have '.' in your include_path your examples work as expected.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jul 02 01:01:34 2025 UTC