set_include_path和get_include_path使用及注意事项
set_include_path 设置默认包含路径
在include或require文件的时候,先在默认包含路径里面找,然后在同目录下找
例:
D:/xampp/htdocs/test/include 下有一文件为cls.mysqli.php
D:/xampp/htdocs/test/ 下有一文件为set_include_path.php
里面的内容为
复制代码 代码如下:
set_include_path('/xampp/htdocs/test/include'); //请注意php里边的'/'代表的不是网站根目录,而是文件所在的盘符,可用echo realpath('/');查看
//若php版本过低,该函数不支持,可用通用版ini_set()
/*查看真实默认包含路径*/
echo realpath(get_include_path());
/*要包含cls.mysqli.php只需要*/
require_once('cls.mysqli.php');
$mysql = new Mysql('localhost','root','','test'); //实例化和之后的查询语句并无错误

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to set the scheduled time for publishing works on Douyin? How does it set the video duration?

Where is the Douyin tag set? How can it be tagged so that it can be pushed accurately?

Do Not Disturb Mode Not Working in iPhone: Fix

How to set the watermark in the middle on Weibo_How to set the watermark in the middle on Weibo

How to set up scheduled publishing on Weibo_Tutorial on how to set up scheduled publishing on Weibo

BTCC tutorial: How to bind and use MetaMask wallet on BTCC exchange?
