Ask a Question related to PHP Bugs, Design and Development.
-
mfr at bmx-chemnitz dot de #1
#40666 [NEW]: handling of relative paths in include()
From: mfr at bmx-chemnitz dot de
Operating system: all
PHP version: 5.2.1
PHP Bug Type: Feature/Change Request
Bug description: handling of relative paths in include()
Description:
------------
To start with, PHP version is irrevelant for this request, regardless what
your bug report form says.
This is Change Request.
Change the way relative includes are handled.
The current way of NOT using the script directory but the current working
directory, while documented, cannot be considered a feature but is clearly
a bug.
A script should NOT have to worry about where it was included from when it
needs to include other files, regardless of the way it includes them
(relative, absolute, relative with "./" / "../").
The way this is implemented generates confusion and, quite frankly, breaks
stuff. Pushing responsibility to properly deal with basic functionality
like this to the user is just wrong.
Following this up with an intended reply to bug #22865:
I am sorry, but how can this not be a bug?
You say the documentation says that
"Relative paths in include/require are always relative to the initial
script, *not* to the file doing the include-ing."
Which, regarding the state of documention, is all fine and well, given
that the documentation describes the wrongness of the behaviour
correctly.
HOWEVER, the behaviour itself is the bug.
How can it be intended that, in any given file, any relative include has
to know where the originally called file is located? Why should it care?
How would it know?
If I have a file x that just knows it needs file y in the parent
directory, then this is all there should be to it.
You claim that "You will need to use some kind of tracking of the base
path for the current invocation.". Pardon me, but this is exactly the kind
of house-keeping that include() itself is supposed to do.
Reproduce code:
---------------
foo/bar.php:
<?php
echo "foo/bar.php ";
include("../baz.inc");
?>
baz.inc:
<?php
echo "baz.inc ";
?>
index.php:
<?php
echo "index.php ";
include("foo/bar.php");
?>
Expected result:
----------------
[url]http://host/foo/bar.php[/url]
"foo/bar.php baz.inc"
[url]http://host/index.php[/url]
"index.php foo/bar.php baz.inc"
Actual result:
--------------
[url]http://host/foo/bar.php[/url]
"foo/bar.php baz.inc"
[url]http://host/index.php[/url]
"index.php foo/bar.php
Warning: main(../test.inc) [missing file...]"
--
Edit bug report at [url]http://bugs.php.net/?id=40666&edit=1[/url]
--
Try a CVS snapshot (PHP 4.4): [url]http://bugs.php.net/fix.php?id=40666&r=trysnapshot44[/url]
Try a CVS snapshot (PHP 5.2): [url]http://bugs.php.net/fix.php?id=40666&r=trysnapshot52[/url]
Try a CVS snapshot (PHP 6.0): [url]http://bugs.php.net/fix.php?id=40666&r=trysnapshot60[/url]
Fixed in CVS: [url]http://bugs.php.net/fix.php?id=40666&r=fixedcvs[/url]
Fixed in release: [url]http://bugs.php.net/fix.php?id=40666&r=alreadyfixed[/url]
Need backtrace: [url]http://bugs.php.net/fix.php?id=40666&r=needtrace[/url]
Need Reproduce Script: [url]http://bugs.php.net/fix.php?id=40666&r=needscript[/url]
Try newer version: [url]http://bugs.php.net/fix.php?id=40666&r=oldversion[/url]
Not developer issue: [url]http://bugs.php.net/fix.php?id=40666&r=support[/url]
Expected behavior: [url]http://bugs.php.net/fix.php?id=40666&r=notwrong[/url]
Not enough info: [url]http://bugs.php.net/fix.php?id=40666&r=notenoughinfo[/url]
Submitted twice: [url]http://bugs.php.net/fix.php?id=40666&r=submittedtwice[/url]
register_globals: [url]http://bugs.php.net/fix.php?id=40666&r=globals[/url]
PHP 3 support discontinued: [url]http://bugs.php.net/fix.php?id=40666&r=php3[/url]
Daylight Savings: [url]http://bugs.php.net/fix.php?id=40666&r=dst[/url]
IIS Stability: [url]http://bugs.php.net/fix.php?id=40666&r=isapi[/url]
Install GNU Sed: [url]http://bugs.php.net/fix.php?id=40666&r=gnused[/url]
Floating point limitations: [url]http://bugs.php.net/fix.php?id=40666&r=float[/url]
No Zend Extensions: [url]http://bugs.php.net/fix.php?id=40666&r=nozend[/url]
MySQL Configuration Error: [url]http://bugs.php.net/fix.php?id=40666&r=mysqlcfg[/url]
mfr at bmx-chemnitz dot de Guest
-
relative include paths? What's the use?
If I were to write an include with a relative path like include("../conf/config.php"); What is the use? As far as I understand it, the path... -
Contribute 3 rewrites PHP include relative paths!
I'm having the same problem, essentially. The DWT file has a path to an include, and in Dreamweaver when you create a new file from the Template, it... -
#26259 [Opn->Bgs]: relative include path not working with include() from shell command line execut
ID: 26259 Updated by: iliaa@php.net Reported By: orsaini at allainet dot com -Status: Open +Status: ... -
#26259 [NEW]: relative include path not working with include() from shell command line execut
From: orsaini at allainet dot com Operating system: Lunux Apache 2.0.47 PHP version: 4.3.2 PHP Bug Type: ... -
Problem with relative paths!!! Help me please!
Hi! I've a big absurd problem with the director's relative path. I must load from my project some pdf's files from the buddyapi xtra but I've...



Reply With Quote

