Set_include_path and require, include introduction-php source code

Source: Internet
Author: User
In php, set_include_path will cause require. The include usage is different. For this problem, let's look at a simple example, as shown below. In php, set_include_path will cause require. The include usage is different. For this problem, let's look at a simple example, as shown below.

Script ec (2); script

In PHP, include and require are often used to reference other files and use relative or absolute paths. If you use the set_include_path function or ini_set ('include _ path', xxx) to set the include_path configuration option, the require file can be referenced directly in other directories.

Set include_path configuration options

For example: require_once "class. smarttemplate. php", this file is not actually in the directory where the current file is located, but can be directly referenced in this way. Because the include_path:

PHP

// Contains the configuration file and library path
Ini_set ('include _ path', INCLUDE_PATH. DS. "library". PATH_SEPARATOR. ini_get ('include _ path '));


Set_include_path Function

The set_include_path function has the same effect as the ini_set ('include _ pram', xxx) function, except that the ini_set method is suitable for all PHP versions. For now, there is no difference between the two.

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.