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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
konstandinos
Forum Commoner
Posts: 68
Joined: Wed Oct 04, 2006 4:20 am

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

Post 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?
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

Post by kaszu »

Code: Select all

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