简体   繁体   中英

Difference between windows and unix paths

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.

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

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM