From: ovdspek at liacs dot nl Operating system: Debian Linux Sarge PHP version: 4.3.9 PHP Bug Type: Scripting Engine problem Bug description: C++ like include (path/search) in PHP?
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 bug report at http://bugs.php.net/?id=30881&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=30881&r=trysnapshot4 Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=30881&r=trysnapshot50 Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=30881&r=trysnapshot51 Fixed in CVS: http://bugs.php.net/fix.php?id=30881&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=30881&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=30881&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=30881&r=needscript Try newer version: http://bugs.php.net/fix.php?id=30881&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=30881&r=support Expected behavior: http://bugs.php.net/fix.php?id=30881&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=30881&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=30881&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=30881&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=30881&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=30881&r=dst IIS Stability: http://bugs.php.net/fix.php?id=30881&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=30881&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=30881&r=float MySQL Configuration Error: http://bugs.php.net/fix.php?id=30881&r=mysqlcfg