Home  >  Article  >  Backend Development  >  PHP include_path setting tips sharing_PHP tutorial

PHP include_path setting tips sharing_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:27:421522browse

1. The meaning of include_path

When the functions include(), require(), and fopen_with_path() are used to find files. When include_path is not set, these functions will default to the web root when opening files. Directory to search. When include_path is set, these php functions will first search under the specified include_path directory.

The principle is similar to the environment variables of the window system. When the window runs the cmd command, enter After some cmd commands are executed, the system will search whether these commands exist in the environment variables set by it, and they can be executed if they exist.
PHP include_path setting tips sharing_PHP tutorial

2.include_path settings
The first method:

Modify the include_path item in the php.ini file.

include_path = .:/usr/local/lib/php:./include
Second method:

Use the ini_set method.
ini_set("include_path", ".:../:./include:../include");   

3. Note
zendframework include setting index.php

Copy code The code is as follows:

set_include_path('.' .PATH_SEPARATOR.'../library/'
.PATH_SEPARATOR .'./application/models/'
.PATH_SEPARATOR.'./application/lib/'
.PATH_SEPARATOR.get_include_path());

PATH_SEPARATOR is a constant in Linux In the system, it is a ":" sign, and on Windows, it is a ";" sign.

So it is best to use the constant PATH_SEPARATOR instead when writing a program, otherwise errors will occur if the system is ported from linux to win or vice versa!
get_include_path gets the current existing environment variables, plus the previous settings, it is the new system include

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/323708.htmlTechArticle1. The meaning of include_path is when the functions include(), require(), and fopen_with_path() are used to find files. .When include_path is not set, the default when these functions open files is...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn