PHP has a nice realpath() function, which can convert something like /dir1/dir2/../dir3/filename to /dir1/dir3/filename. The “problem” with this function is that in case /dir1/dir3/filename is not an actual file but merely a link to another file, PHP would follow that link and return the real path of the actual file.
However, I actually need to get the real path of the link itself. All I need is to resolve complexities like /dir/.. in the path. How can I do it?
I was hoping to find an existing PHP function that does that, or else something simple along the lines of xdazz’s answer (but that would actually work the way I want it to). Having failed to find such an answer, I’ve written my own dirty function. I’d be happy to hear your comments and suggestions for improvement!