I am building a path string in PHP. I need it to work on different platforms (e.g. Linux, Windows, OS X). I'm doing it:
$path = $someDirectory.'/'.$someFile;
Suppose that $someDirectory and $someFile formatted correctly at runtime on different platforms. This works great on Linux and OS X, but not on Windows. The problem is with the / character, which I thought would work for Windows.
Is there a PHP function or some other trick to switch this to \ at runtime on Windows?
EDIT: To be clear, the resulting string
c:\Program Files (x86)\Sitefusion\Sitefusion.org\Defaults\pref/user.preferences
on Windows. Obviously, a slash combination is confusing Windows.
directory php filepath
retrodrone Jul 11 2018-11-17T00: 00Z
source share