Edit report at https://bugs.php.net/bug.php?id=46260&edit=1
ID: 46260 Comment by: tony at brown dot org 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: 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. :-( Previous Comments: ------------------------------------------------------------------------ [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" ------------------------------------------------------------------------ [2010-12-10 18:12:17] php at micropro dot cz I think I have a resoulution ... use $_SERVER["SCRIPT_FILENAME"] instead of __file__. It should work the same way, but is absolute path, not resolved. It works for me fine :-) ------------------------------------------------------------------------ [2010-11-10 16:52:41] jimmy at powerzone dot dk I agree. Hosting multiple PHP systems based on the same installation is no easy task, when __FILE__ is used in conjunction with symlinks. Very frustrating. I vote for a new contant; __FILEPATH__ which does not resolve symlinks. ------------------------------------------------------------------------ [2010-08-26 09:12:33] rix at mindginative dot com +1 for this. I encountered this issue today and was hoping that there's a better way not to resolve symlink in __FILE__. As suggested above, perhaps __FILE_LINK__ that either return the symlink path or false if none. ------------------------------------------------------------------------ [2009-09-26 21:01:15] miguel-php at cr dot uz Another vote for this. The current implementation does not seem like the proper way to treat symlinks, and it makes sharing included files between directories very difficult. I understand that changing this now has the potential to cause breakage in scripts that depend on the current behaviour. But there really does need to be a way for a file to find its own effective location. ------------------------------------------------------------------------ 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