ID: 41486
Updated by: [EMAIL PROTECTED]
Reported By: tayloj1 at uk dot ibm dot com
Status: Open
Bug Type: Documentation problem
PHP Version: Irrelevant
New Comment:
I haven't verified, but here's a patch if the behavior is indeed
correct (I'm inclined to believe this reporter, but there's no harm in
double-checking):
Index: en/language/control-structures.xml
===================================================================
RCS file: /repository/phpdoc/en/language/control-structures.xml,v
retrieving revision 1.138
diff -u -r1.138 control-structures.xml
--- en/language/control-structures.xml 7 May 2007 09:33:54 -0000 1.138
+++ en/language/control-structures.xml 26 May 2007 13:28:46 -0000
@@ -1308,7 +1308,7 @@
in that file, <filename>b.php</filename> is first looked in
<filename class="directory">/www/</filename>
and then in <filename class="directory">/www/include/</filename>.
If filename begins with <literal>./</literal> or
<literal>../</literal>, it
- is looked only in include_path relative to the current working
directory.
+ is only looked for relative to the current working directory.
</simpara>
<simpara>
When a file is included, the code it contains inherits the
Previous Comments:
------------------------------------------------------------------------
[2007-05-24 09:55:07] tayloj1 at uk dot ibm dot com
Description:
------------
ref: http://uk.php.net/include/
If the file for including starts with ./ or ../, include_path is not
taken into account.
The statement:
"If filename begins with ./ or ../, it is looked only in
include_path relative to the current working directory. "
should be replaced with:
"If the filename begins with ./ or ../, it is only looked for
relatively to the current working directory."
as demonstrated by the following experiment (tested on Windows and php
5.2.2):
Reproduce code:
---------------
Directory layout:
\myScriptDir
\a.php <?php include './b.php' ?>
\myWorkingDir
\php.exe
\php.ini [...] include_path='include1;include2' [...]
Execute:
\myWorkingDir> php \myScriptDir\a.php
Expected result:
----------------
Doc says: "it is looked only in include_path relative to the current
working directory"
Expected attempted file reads (if the documentation were correct):
\myWorkingDir\include1\b.php
\myWorkingDir\include2\b.php
Actual result:
--------------
Actual attempted file reads:
\myWorkingDir\b.php
Result obtained by stepping through the code with a debugger (namely
_php_stream_fopen_with_path() in plain_wrapper.c) and confirmed with
processmonitor, a tool which can monitor filesystem activity
(http://www.microsoft.com/technet/sysinternals/utilities/processmonitor.mspx)
So files were only looked for relatively to the current working
directory and the include path was not taken into account.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=41486&edit=1