From: rpeters at icomproductions dot ca Operating system: CentOS 4.3 PHP version: 5.2.6 PHP Bug Type: Feature/Change Request Bug description: Runtime equivilant of __FILE__
Description: ------------ Since __FILE__ is defined at compile-time, it means that files that "change location" (eg: are renamed, or hard-linked with multiple filenames) execute incorectly when pre-compiled. This is especially evident with op-code caches such as APC. So __FILE__ either needs to be determined at runtime, or a runtime accessible alternative needs to be provided. I propose $_SERVER['PHP_FILE'], and would like documentation updated to recommend people use it rather than __FILE__. Obviously, __DIR__ would need the $_SERVER['PHP_DIR'] variable for the same reasons. Reproduce code: --------------- CURRENTLY: /1/test.php: <?php require(__DIR__ . '/testDest.php'); ?> /2/test.php created by "cp -l ../1/test.php" /1/testDest.php: <?php echo 1; ?> /2/testDest.php: <?php echo 2; ?> PROPOSED: /1/test.php: <?php require($_SERVER['PHP_DIR'] . '/testDest.php'); ?> /2/test.php created by "cp -l ../1/test.php" /1/testDest.php: <?php echo 1; ?> /2/testDest.php: <?php echo 2; ?> Expected result: ---------------- /1/test.php displays "1", and /2/test.php displays "2" Actual result: -------------- CURRENTLY: When running APC, both scripts will return the results of whichever one you hit first. PROPOSED: When running APC, /1/test.php displays "1", and /2/test.php displays "2" -- Edit bug report at http://bugs.php.net/?id=45421&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=45421&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=45421&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=45421&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=45421&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=45421&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=45421&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=45421&r=needscript Try newer version: http://bugs.php.net/fix.php?id=45421&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=45421&r=support Expected behavior: http://bugs.php.net/fix.php?id=45421&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=45421&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=45421&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=45421&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=45421&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=45421&r=dst IIS Stability: http://bugs.php.net/fix.php?id=45421&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=45421&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=45421&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=45421&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=45421&r=mysqlcfg