Difference between windows and unix paths

只谈情不闲聊 提交于 2019-12-12 02:16:48

问题


My test server is windows. Live server is unix.

I was using relative paths, which seemed to work identically on both. I changed to absolute paths and it seems the two are different.

My problem stems from files being loaded from subdirectories. On the windows server I am using realpath(), and this seems to give me a 'root' to locate from. But unix treats this different?

What is the usual method of matching unix absolute paths to windows?

Problem Found : The cause was require().

It seems windows permits a 'superfluous' '/' prefixed, so

require '/ajax/test.php' is valid on windows but not on unix.


回答1:


I would suggest that, considering you are working on different environments for live and dev, you restrict upload folders and that you create a static map between your Windows and Linux environments.

Also, just in case you haven't seen this, the documentation on PHP.net about realpath describes the differences between Linux and Windows quite clearly:

http://php.net/manual/en/function.realpath.php




回答2:


I would suggest to have defined/static variables in config file which is loaded everywhere. It's easy very reliable approach IMHO.




回答3:


Problem Found : The cause was require().

It seems windows permits a superfluous '/' prefixed, so

require '/ajax/test.php'` is accepted on windows but unix returns an error.



来源:https://stackoverflow.com/questions/8627416/difference-between-windows-and-unix-paths

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!