To put it simply, #include file is followed by the "relative path" of the file, and #include virtual is followed by the "absolute path" of the file.
The "relative path" mentioned here is relative to the folder where the "main file" is located.
#include file
#include file is followed by the "relative path" of the file, and "absolute path" cannot be used.
Use relative paths, such as: file="script/file.inc", file="../script/file.inc"
Absolute paths cannot be used, such as: file="/script/file.inc"
#include virtual
#include virtual can be followed by the "absolute path" of the file, or by the formal "relative path" (the so-called formal "relative path" means that the path is formally a "relative path", but it It will still be converted into an "absolute path", so it is still essentially an "absolute path")
Use absolute paths, such as: virtual="/folder/file.inc"
Use a formal "relative path", such as: virtual="folder/file.inc", which will be converted to virtual="/folder/file.inc"
It is recommended to use the "absolute path" form, such as: virtual="/folder/file.inc" instead of virtual="folder/file.inc", although it can be written like this.
Let’s talk about the differences with a few examples:
Copy the code code as follows:
Assuming that the "included file" and the "included file" are in the same folder named folder in the root directory, virtual="folder/file.asp" is OK, but file="folder/file.asp" is wrong of.
If there are two folders folder1 and folder2 under a site, there is file file1.asp under folder1, and file file2.asp under folder2. If file1.asp wants to call file2.asp, then you can write this in file1.asp:
<!--#include virtual="/folder2/file2.asp"-->,
It is wrong to use <!--#include file="folder2/file2.asp"--> in this case.
During use, please pay attention to the following points:
Regardless of whether you use #include file or #include virtual, you can use just "/" or just "/" in the path, or a mixture of the two.
For example: file="../script/file.inc", file="../script/file.inc", file="../script/file.inc"
#include file and #include virtual can only include files within the site, not files outside the site. For example, assuming there is a site named website, using virtual="website/file.asp" is wrong.