php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #38339 Wanted: Find included file first in the script's path, than include_path option
Submitted: 2006-08-05 02:10 UTC Modified: 2017-01-29 04:22 UTC
From: me at daybreaker dot info Assigned:
Status: No Feedback Package: *General Issues
PHP Version: 5.1.4 OS: Linux Ubuntu 6.06 LTS (Server)
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: me at daybreaker dot info
New email:
PHP Version: OS:

 

 [2006-08-05 02:10 UTC] me at daybreaker dot info
Description:
------------
I've found that PHP finds included files (specified by 'include', 'include_once', 'require', 'require_once' functions) first in 'include_path' option, earlier than the current script file's path.

I think it's more feasible that the first search should be done in the current script file's path, rather than the current working directory specified in 'include_path' option.

If there are some included files which have same name (and not same pathes), PHP simply ignores the files who is included later in a context (or reinclude the first file when 'once' is not specified), though there may exist some cases that someone includes files which have same names, but are in the same directory in which the current script file is.

Reproduce code:
---------------
(Without touching 'include_path' option, it contains '.:/usr/share/php:/usr/share/pear' by default)
* test.php
include("config.php");
include("foo/test.php");

* config.php
echo "config.php<br>";

* foo/test.php
include("config.php");

* foo/config.php
echo "foo/config.php<br>";

Expected result:
----------------
config.php
foo/config.php

Actual result:
--------------
config.php
config.php

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-08-05 02:46 UTC] me at daybreaker dot info
The feature that is included at PHP 4.0.7 by Adny still works well, but I want you to change the search order.

If there exists foo/config2.php which prints "foo/config2.php" and add include("config2.php"); into foo/test.php, the expected result is:
config.php
foo/config.php
foo/config2.php
and the actual result is
config.php
config.php
foo/config2.php

So there's no bug in the original feature. I just want to change the search order.
 [2017-01-20 21:50 UTC] heiglandreas@php.net
-Status: Open +Status: Feedback -Package: Feature/Change Request +Package: *General Issues
 [2017-01-20 21:50 UTC] heiglandreas@php.net
Is this still relevant?
 [2017-01-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 16:01:28 2024 UTC