Set_include_path set default include path
In the include or require file, first look in the default include path, and then look in the same directory
Cases:
There's a file under D:/xampp/htdocs/test/include for cls.mysqli.php.
There's a file under d:/xampp/htdocs/test/for set_include_path.php.
The content inside is
Copy Code code as follows:
Set_include_path ('/xampp/htdocs/test/include '); Please note that the '/' inside of PHP is not the root of the site, but the letter of the file, available with echo realpath ('/');
If PHP version is too low, this function does not support, can be used General Edition Ini_set ()
/* View the true default include path * *
Echo Realpath (Get_include_path ());
* * To include cls.mysqli.php only need * *
Require_once (' cls.mysqli.php ');
$mysql = new MySQL (' localhost ', ' root ', ' ', ' test '); No errors in instantiated and subsequent query statements