require_once如何“检查文件是否已被包含”?

I assume it doesn't actually hash the file contents, does it stick all of the require'd pathnames into an internal hash table?

The context for this is that I'm getting some (redeclaration) warnings that would make sense if require_once was getting confused by slightly different paths to the same file, and I'd obviously rather not load files multiple times.

require_once() will only keep track of unique file access paths.

  • If the same content inside two files accessed, they will treated as different files (intuitive)
  • If the same physical file is accessed via two different paths, it will be treated as different files. (less intuitive)
  • If a physical file is accessed, later a symlink to the same physical file, it will be treated as different files (least intuitive)