0

i change the dir to the current file directory to :

chdir(dirname(__FILE__));

But how do i change it back to the base director like / in linux and say C: in windows i dont know that is the OS of the user.

Is there a way to do it in both linux and win ?

hakre
  • 193,403
  • 52
  • 435
  • 836
kritya
  • 3,312
  • 7
  • 43
  • 60

2 Answers2

0

PHP will translate directory separators for you, so just chdir('/') will work on both. However, you'd have to account for Windows drive names, as there's no such thing on Unix systems.

Marc B
  • 356,200
  • 43
  • 426
  • 500
0

The answer to this question: How to get the OS on which PHP is running? might help you determine the OS.

Try using php_uname()

Community
  • 1
  • 1
Naftali
  • 144,921
  • 39
  • 244
  • 303