Edit report at https://bugs.php.net/bug.php?id=46260&edit=1
ID: 46260 Comment by: contato at mesotec dot com dot br Reported by: bugs dot php dot net at callum-macdonald dot com Summary: __FILE__ should not resolve symlink paths Status: Open Type: Feature/Change Request Package: Feature/Change Request Operating System: Linux PHP Version: 5.2.6 Block user comment: N Private report: N New Comment: +1 too. I really need this feature. In windows 7 realpath for a file that is accessed through a mklink folder does return the link path not the absolute one. Previous Comments: ------------------------------------------------------------------------ [2011-12-26 15:51:42] bugs dot php dot net at callum-macdonald dot com I tested monsen.dag's suggestion and it produced a completely different result than expected. Also, defining a constant will only apply once, not to the *currently executing file*, which is the great advantage of __FILE__. This suggestion does not provide a solution of any kind as far as I can tell. ------------------------------------------------------------------------ [2011-12-22 13:45:24] monsen dot dag at gmail dot com If you're on an enviroment with bash available, you can use this snippet to get __FILE__ without resolving symlinks. It's a small hack, but it should be pretty safe. <?php $output = array(); exec('pwd', &$output); define('__LINK__', $output[0].substr(__FILE__, strpos(__FILE__, DIRECTORY_SEPARATOR))); ?> ------------------------------------------------------------------------ [2011-10-25 19:45:34] nars at clix dot pt +1 ------------------------------------------------------------------------ [2011-07-26 16:54:10] tony at brown dot org I'm another +1 for this, causing me some real headaches because for deployment I store multiple versions of a site with the latest been symlinked to for apache. There are modules in the application which are licensed and use the file path as part of it's verification. When we deploy, the path is seen as changed and the modules get disabled. :-( ------------------------------------------------------------------------ [2011-04-27 04:38:48] gnoodl+php at gmail dot com $_SERVER["SCRIPT_FILENAME"] cannot be used in place of __FILE__ as it does not resolve the path of an included file. Eg, // file1.php include 'file2.php'; // file2.php echo $_SERVER['SCRIPT_FILENAME']; Executing file1.php will result in "/path/to/file1.php" ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=46260 -- Edit this bug report at https://bugs.php.net/bug.php?id=46260&edit=1