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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

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

SublimeText3 Linux new version
SublimeText3 Linux latest version

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
