问题
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