useCase useCase - 3 months ago 11
PHP Question

How can I define the DIRECTORY_SEPARATOR for both Windows and Linux platforms?

Now I create a small PHP Application, here I have problem for using file path, because in Windows use this type location

C:\Some\Location\index
but in
Linux /www/app/index
so when I define the path using this
/
but when the application run in window machine it should be problem for this
/
.

So here I want to define the DIRECTORY_SEPARATOR both Windows and Linux platform.

Answer

PHP accepts both \ and / as valid path separators in all OS. So just use / in your code