Bug #12301 Updated: include() in included file should check included file's directory
| From: | cnewbill@php.net | Date: | Sat, 21 Jul 2001 20:04:25 +0000 |
| Subject: | Bug #12301 Updated: include() in included file should check included file's directory | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-60490@lists.php.net to get a copy of this message | ||
ID: 12301
Updated by: cnewbill
Reported By: marv@cyberia.net.lb
Status: Bogus
Bug Type: Feature/Change Request
Operating System: Any
PHP Version: 4.0.6
New Comment:
I guess I should clarify this.
The behavior is that when an include()/require() is issued it checks the include_path in the order
specified.
So say my program is in /www and my scripts are in /www/scripts. My include_path has been modified
to include /www/scripts/.
if I do include("main.php") in /www/index.php , then php first checks the working
directory which is /www, it sees I have no main.php here so it checks the next entry in include_path
/usr/local/lib/php/...still no dice, finally it checks /www/scripts...voila it finds it and includes
it without me having to know the path.
-Chris
Previous Comments:
------------------------------------------------------------------------
[2001-07-21 15:57:26] cnewbill@php.net
No you're not the only one who does this.
You just need to modify your php.ini include_path setting.
By default it is ".:/usr/local/lib/php/", i.e. check the current directory then check
/usr/local/lib/php/.
So you would want yours to be ".:/usr/local/lib/php/:/path/to/scripts". Then you could do
this.
<?php
include("main.php");
include("admin/tools.php");
include("include/process.inc");
include("include/lib.inc");
// rest of code here
?>
-Chris
------------------------------------------------------------------------
[2001-07-21 15:29:09] marv@cyberia.net.lb
When using include(), it should check the current file's directory. Currently PHP start from
the script's directory.
Say you have the following files:
scripts/main.php
scripts/admin/tools.php
scripts/include/process.inc
scripts/include/lib.inc
If process.inc wants to include lib.inc, you would need to know from where it was included. If you
started off from main.php, main.php would have include('include/process.inc') and
process.inc would have include('include/lib.inc'). If you started off from tools.php,
tools.php would have include('../include/process.inc') and process.inc would have
include('../include/lib.inc').
Which is very silly, IMO. process.inc needs lib.inc, and i can make sure they're together in
the same directory, so i can simply use include('lib.inc') in process.inc. why should i
have to care what script and in what directory included process.inc?
I can't believe this feature isn't there. I checked all over the place but it seems it
isn't. Am I the only one who uses more than one directory for my scripts?
If this feature breaks some old scripts, you could have an option in the config file to turn it on
or off.
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=12301&edit=1