Use and precautions of set_include_path and get_include_path_PHP tutorial

WBOY
Release: 2016-07-21 15:13:33
Original
871 people have browsed it

set_include_path sets the default include path
When you include or require a file, first look for it in the default include path, and then look for it in the same directory
Example:
D:/xampp/htdocs/test/include There is one below The file is cls.mysqli.php
D:/xampp/htdocs/test/ There is a file under set_include_path.php
The content inside is

Copy code The code is as follows:

set_include_path('/xampp/htdocs/test/include'); //Please note that the '/' in php does not represent the root directory of the website, but the location of the file drive letter, you can use echo realpath('/'); to view
//If the PHP version is too low, this function is not supported, you can use the general version ini_set()
/*View the real default include path*/
echo realpath(get_include_path());
/*To include cls.mysqli.php just*/
require_once('cls.mysqli.php');
$mysql = new Mysql('localhost ','root','','test'); //There are no errors in instantiation and subsequent query statements

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/326493.htmlTechArticleset_include_path When setting the default include path in the include or require file, first find it in the default include path, and then in the same Find an example in the directory: D:/xampp/htdocs/test/include There is an article...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template