Use stat() to tell you about the file at the end of any chain of symbolic links; it will not lead you to the path in any way. Use lstat() to get information about a symbolic link, if any, called; it acts like stat() when the specified name is not a symbolic link. Use readlink() to get the path name stored in the symbolic link named as its argument (beware - this does not mean that null terminates the line).
If you need the full path to the file at the end of the symlink, you can use realpath() . This gives you an absolute path name that does not cross any symbolic links to access the file.
source share