In PHP, the dirname () function returns the directory portion of the path, __file__ the full path and file name of the currently running file. If used in the included file, the included file name is returned. This is a magic variable (predefined constants), in Windows there is no problem but the path in Linux problems, let's take a look at the path problem resolution.
In the recent development of WordPress template features, found that the use of include ("filename") in the form of other PHP code snippets will appear when the path error. The server environment has always been IIS, and no similar bug has occurred, but a path call error occurred after switching to a Linux server. After searching the Web, you can use DirName (__file__) To troubleshoot path errors when the Linux server contains files under the call.
In fact, the main problem is from the Linxu server root directory problems, when the Linux server contains a file, its path is/home/web/. If you use the format of include ("/filename") directly, the file path that is actually contained is the/home/web/file name.
The complete use method is include DirName (__file__). '/page.php '
This code references a file that needs to be in the same directory as the code file, and if you need to call the previous level directory, you can use DirName (dirname (__file__)) to invoke the file on the previous level of the directory.
If you encounter a problem with a class after the site has changed the server, check to see if the site has a reference path error. It is recommended that you use the DirName (__file__) method to refer to files when writing PHP inclusions to address the most problematic references.