php中setcookie|php中set_include_path和require,include介绍

更新时间:2020-09-19    来源:php函数    手机版     字体:

【www.bbyears.com--php函数】

在PHP中经常使用include,require来引用其他文件,使用相对路径或者绝对路径,如果通过set_include_path函数或者ini_set(‘include_path’,xxx)设置include_path配置选项,那么require文件如果在其他目录也可以直接引用。

设置include_path配置选项

如:require_once “class.smarttemplate.php”,这个文件其实并不在当前文件所在目录,但是同样可以这样直接引用。因为前面通过ini_set设置了include_path:

PHP

// 包含配置文件和函数库路径
ini_set("include_path", INCLUDE_PATH . DS . "library" . PATH_SEPARATOR . ini_get("include_path"));


set_include_path函数

set_include_path函数和ini_set(‘include_pah’,xxx)作用是一样的,只不过ini_set方式适合所有PHP版本,对现在来说两者没有差别。

本文来源:http://www.bbyears.com/jiaocheng/99683.html