There are two forms of the include statement: Virtual and File:
By using Virtual, you can include any file no matter what its location because Virtual starts as the root directory of the site. In contrast, the File statement starts in the CURRENT directory (the same directory as the file containing the Include).
Example #1could include a file from the AAA directory, even if the page with this statement is in the /BBB/ folder.
Example #2:would fail when used in any file not located in the AAA directory.
Example #3:will succeed from any directory on the same level as the AAA directory. It's instructing the include to go up one directory and then into the AAA directory to get the file. However, if the page that contains the include is moved to a different level in the directory structure, the Include statement would fail.
I almost always use the Virtual format. That way I know I'm starting at the site root. Even if I move the page containing the include to a different directory, it will still work.
No comments:
Post a Comment