Recently, when developing templates for wordpress, we found that path errors may occur when calling other php code snippets in the form of include ("file name. Previously, the server environment was always iis, and no similar bugs were found. However, after being replaced with a linux server, a path call error occurred. I searched the internet and found that the dirname (_ FILE _) can be used to solve the path error when the linux Server contains files.
In fact, the main problem is the root directory of the site under the linxu server. When the linux Server contains a file, the path is/home/web /. If you directly use the include ("/file name") format, the actually contained file path is/home/web/file name.
The complete method is include dirname (_ FILE _). '/page. php'
The FILE referenced by this code must be in the same directory as the FILE where the code is located. If you need to call the previous directory, you can use dirname (_ FILE __)) to call the files in the previous directory.
If you encounter inclusion problems after changing the server, check whether the website has a Reference Path error. We recommend that you use the dirname (_ FILE _) method to reference a FILE when writing a php FILE to solve the reference problem in most cases.