当前位置: 动力学知识库 > 问答 > 编程问答 >

php change directory to base directory

问题描述:

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 ?

网友答案:

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.

网友答案:

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()

分享给朋友:
您可能感兴趣的文章:
随机阅读: