Path management in php

I’m interested to see how other people do this, since it’s something that I don’t often have to manage myself, but on my current project appears to be pretty important.

I want to be able to use the full path to files on the file system in my code, but also allow it to be cross platform (ie on windows and *nix machines). I normally use:


$pathToFile = dirname(__FILE__) . '/'

echo $pathToFile;

// Linux output
# /home/site/dir/

//Windows output
# C:\home\site\dir/

but of course, that will cause problems on windows machines that use the backslash to seperate directories. Anyone have a solution for managing this (other than using relative directories!)