PHP include file loading

Source: Internet
Author: User
: 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.

  1. 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.

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.