`$path` should use `DIRECTORY_SEPARATOR` rather than `/`. Otherwise you are changing the behavior of `realpath()` and will cause unexpected problems.