Page 1 of 1

Determine OS

Posted: Sat Apr 15, 2006 8:51 pm
by alex.barylski
Currently I'm using the PHP_OS constant

I need to determine if I'm on Windows or a *nix because I have a script which splits() paths on directory delimiters...

Code: Select all

$arr1 = split('/', strtolower($path1));
Should I use this OS specific approach or can I use regex to split on either?

On Windows can you not use both / or \ slash to delimit directories?

The code above only works on my production server *nix, but when I tried it on my desktop obviously it crapped all over me :roll:

What is a good, cross platform way of spliting a path into individual directory units?

Cheers :)

Posted: Sat Apr 15, 2006 8:56 pm
by feyd
ahem:

Code: Select all

DIRECTORY_SEPARATOR

Posted: Sat Apr 15, 2006 9:00 pm
by alex.barylski
feyd wrote:ahem:

Code: Select all

DIRECTORY_SEPARATOR
Oh nice :)

You da' man brah!!!