: This article mainly introduces PHP's include file loading. if you are interested in the PHP Tutorial, refer to it.
Include into de_once require require_once all belong to the syntax structure, rather than the function. The difference between File loading errors and file duplication
Include ";
Include (");
In the include syntax of php, if there is no path but only a file name, include has its own search rules.
- Find
In php. the ini configuration file contains the include_path configuration item. you can set multiple directories. The system will search for the files to be loaded in sequence (note that the separators of different systems are different)
; UNIX: "/path1:/path2";include_path = ".:/php/includes";; Windows: "\path1;\path2";include_path = ".;c:\php\includes"
You can also set the value of include_path in the code, which is only valid for the current code and does not need to restart apache.
set_include_path('.dir.');
You can also obtain the value of the current include_path.
$ Path = get_include_path (); $ path_add = $ path. PATH_SEPARATOR. '. dir.'; // PATH_SEPARATOR is a system function, representing the separator; |: set_include_path ($ path_add );
2. if none of the above is found, search for the current webpage File (current working directory)
3. if not found, search for the directory where the include syntax is located (multi-layer nesting)
File loading and execution process
Exit php mode from include statement to html mode
Load the code in the include file and execute
Exit html mode and enter php mode
Function of the return keyword in the loaded file
1 is returned when the include statement is loaded by default, and false is returned if an error occurs.
In the contained file, you can use the return statement to end the return value of code execution.
The return value can also be received and processed.
$val = include'.dir.';
'). AddClass ('pre-numbering '). hide (); $ (this ). addClass ('Has-numbering '). parent (). append ($ numbering); for (I = 1; I <= lines; I ++) {$ numbering. append ($ ('
'). Text (I) ;}; $ numbering. fadeIn (1700) ;}) ;}; script
The above introduces PHP's include loading file, including some content, and hope to be helpful to friends who are interested in PHP tutorials.