#30881 [Opn->Bgs]: C++ like include (path/search) in PHP?
| From: | tony2001@php.net | Date: | Thu, 25 Nov 2004 21:55:26 +0000 |
| Subject: | #30881 [Opn->Bgs]: C++ like include (path/search) in PHP? | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-69449@lists.php.net to get a copy of this message | ||
ID: 30881
Updated by: tony2001@php.net
Reported By: ovdspek at liacs dot nl
-Status: Open
+Status: Bogus
Bug Type: Scripting Engine problem
Operating System: Debian Linux Sarge
PHP Version: 4.3.9
New Comment:
PHP CLI "does not change the working directory to that of the script"
(c) http://www.php.net/manual/en/features.commandline.php
In your case documentation says about other SAPIs.
Previous Comments:
------------------------------------------------------------------------
[2004-11-24 14:45:34] ovdspek at liacs dot nl
Oops, forgot to reopen.
------------------------------------------------------------------------
[2004-11-24 14:34:58] ovdspek at liacs dot nl
And doesn't the documentation claim to already search relative to the
script dir?
> and then in include_path relative to the directory of current script.
------------------------------------------------------------------------
[2004-11-24 14:33:16] ovdspek at liacs dot nl
I'm asking for an addition, not a modification.
What kind of scripts would be broken if you search additional paths
(after searching in the old way)?
------------------------------------------------------------------------
[2004-11-24 14:29:14] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php
This is expected, and we can not change this as it will break a lot of
scripts.
------------------------------------------------------------------------
[2004-11-24 14:25:06] ovdspek at liacs dot nl
Description:
------------
In PHP, includes (appear to) use the current working directory. In C++,
includes use the directory of the including script (and the include
path).
Could the C++ behaviour be added to PHP includes?
Because if relative includes are used, current PHP scripts can only be
executed if cwd == script dir.
Reproduce code:
---------------
$ cat 1.php
<?php
echo "1.php<br>\n";
?>
$ cat b/2.php
<?php
include('../1.php');
?>
$ php -f b/2.php
Warning: main(../1.php): failed to open stream: No such file or
directory in /home/olaf/t/a/b/2.php on line 2
Warning: main(): Failed opening '../1.php' for inclusion
(include_path='.:/usr/share/php:/usr/share/pear') in
/home/olaf/t/a/b/2.php on line 2
$ cd b
$ php -f b/2.php
Could not open input file: b/2.php.
$ php -f 2.php
1.php<br>
$
Expected result:
----------------
Warning: main(../1.php): failed to open stream: No such file or
directory in /home/olaf/t/a/b/2.php on line 2
Warning: main(): Failed opening '../1.php' for inclusion
(include_path='.:/usr/share/php:/usr/share/pear') in
/home/olaf/t/a/b/2.php on line 2
Actual result:
--------------
1.php<br>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=30881&edit=1