The backslash is a directory delimiter on the Windows platform. But from what I understood and experienced, when resolving paths, your PHP script will work with a slash. As a result, you can write all your code using slashes and not worry about it. Direct / feedback is really important only if you show the path to the user, for example, in the installer / installer script (most users of the site will not need to know about directory structures and do not care about which platform the service works for). You can create a mapping function that identifies the platform and, if necessary, replaces the slashes, and then passes the paths through it before showing them. Below is an example of what I offer, although I have not tested it.
<?php function platformSlashes($path) { if (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN') { $path = str_replace('/', '\\', $path); } return $path; } $path = "/some/path/here"; echo platformSlashes($path);
source share