You can replace them with a constant DIRECTORY_SEPARATOR.
Or just use slashes and
$string = str_replace('/', DIRECTORY_SEPARATOR, $string);
To make this constant less cumbersome, you can do it
define('DS', DIRECTORY_SEPARATOR);
Joomla does it.
, , escape-.
, str_replace() .