First, let's look at the description of the file search principles for include in the official PHP manual:
Files for including is first looked for with each include_path entry relative to the current working directory, and then in The directory of current script. e.g. if your include_path is libraries, current working directory are, you included and there are include "b.php" C2/>in that file, was first looked in and so in . If filename begins with./ or. /, it is looked with the current working directory.
The order in which to find the included files is looked for in the relative include_path of the current working directory, and then include_path under the current directory where the script is currently running. For example Include_path is . , the current working directory is, the script to include one and in the file has an include "b.php" , then the order of the search is first, then. If the file name is. / or : / Start, search only under the include_path of the current working directory.
So the file structure as shown below
----a.php
----include/b.php
----include/c.php
where a.php
<?phpinclude ' include/b.php ';? >-----------------------b.php<?phpinclude ' c.php ', include ' include/c.php ';? >
--------------------------
c.php
<?phpecho ' c.php ';? >
--------------------------
Can be run correctly, indicating that two different include paths in b.php are feasible, and c.php can be found in the way that include searches for included files.
But the best way is to use absolute path, if the absolute path is used, the PHP kernel directly through the path to load the file without going to include path to search for files, increase the efficiency of code execution
<?phpdefine (' Root_path ', DirName (FILE)); include Root_path. ' /c.php ';? >
Different file inclusion methods, the execution performance of the program can be compared to the specific reference to this article
<script type= "Text/javascript" ><!--google_ad_client = " ca-pub-1944176156128447 ";/* cnblogs home Banner */google_ad_slot =" 5419468456 "; google_ad_width = 728;google_ad_height = 90;// --></script><script type= "Text/javascript" src= "</SCRIPT>