Page 1 of 1

getcwd() for different OS - how to detect directory delim?

Posted: Wed Feb 07, 2007 2:07 am
by konstandinos
hi all

im using getcwd to return the current working directory (ie: d:\code\moo) on my windows evironment. i assign this value to a string. i then want to concatenate a sub-directory to teh string, ie: getcwd() . "\foo"

this works fine and all, but if its in a unix environment, the getcwd() would return /code/moo, and i'd be appending "\foo" instead of "/foo".

how do i solve this?

Posted: Wed Feb 07, 2007 2:25 am
by kaszu

Code: Select all

getcwd() . DIRECTORY_SEPARATOR . "foo"
DIRECTORY_SEPARATOR - predefined constant by PHP