|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2008-10-09 01:32 UTC] bugs dot php dot net at callum-macdonald dot com
Description: ------------ See these bugs: http://bugs.php.net/bug.php?id=38790 http://bugs.php.net/bug.php?id=42516 http://bugs.php.net/bug.php?id=37603 The __FILE__ constant should not, in my opinion, resolve symbolic links on *nix operating systems. At the very least, there should be an option to control this behaviour. Because __FILE__ returns only the symlink resolved path, there is no way to get the symlink path of the currently included file. If __FILE__ returned the symlinkpath, the resolved path could be retrieved with realpath(__FILE__). The opposite is not true. There is no way to go from the resolved path to the original link path. I realise this is a feature not a bug, but I believe it is a serious shortcoming and limits the ability of PHP in symlinked situations. Reproduce code: --------------- See http://bugs.php.net/bug.php?id=37603 Expected result: ---------------- __FILE__ should return the symlink path Actual result: -------------- __FILE__ returns the resolved path PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 10:00:01 2025 UTC |
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))); ?>