donpvtzuux37724 2017-12-21 09:09
浏览 104
已采纳

在魔术常量__FILE__的描述中,“符号链接已解决”是什么意思?

I'm using PHP 7.2.0

Below is a description of magic constant __FILE__ :

The full path and filename of the file with symlinks resolved. If used inside an include, the name of the included file is returned.

I didn't understand meaning of the clause "filename of the file with symlinks resolved"

Someone please make me understand the meaning of this clause with demonstrative suitable example of usage of magic constant __FILE__ accompanied by appropriate explanation.

  • 写回答

1条回答 默认 最新

  • dongre8505 2017-12-21 09:14
    关注

    Symlinks (symbolic links) are "shortcuts" you can create in the filesystem to point one directory entry at any arbitrary other directory entry. On a *NIX shell, something like:

    $ ln -s /foo/bar.php /baz
    

    This establishes /baz as a symlink to /foo/bar.php. Whichever file you use now, they're effectively both the same.

    Resolving symlinks means to look at a given path, recognise symlinks within it and replace them by the actual file path they point to. So, regardless of whether you do

    $ php /baz
    

    or

    $ php /foo/bar.php
    

    the __FILE__ constant will be resolved to the actual file path /foo/bar.php.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?