Absolute vs. relative paths

后端 未结 5 834
温柔的废话
温柔的废话 2020-11-30 03:02

If I use absolute paths, I can\'t move the whole directory to a new location. If I use relative paths, I can\'t move individual files to new locations.

What\'s the s

5条回答
  •  醉酒成梦
    2020-11-30 03:23

    Absolute paths are better from a performance point of view when using an opcode cache or lots of require/include statement (although its only noticeable when you start to include hundreds of files, as might happen when using a framework like Zend/Symfony/etc).

    With a relative path the opcode cache and php must work out the files realpath each time before it can work out if it already knows about the file and if it needs to load it again. PHP internally maintains a hashmap of files to file locations which is very quick as long it doesn't have to do the above calculation each time.

提交回复
热议问题