set_include_path
(PHP 4 >= 4.3.0, PHP 5, PHP 7, PHP 8)
set_include_path — 设置 include_path 配置选项
返回值
成功时返回旧的 include_path 或者在失败时返回 false
。
示例
示例 #1 set_include_path() 示例
<?php
set_include_path('/usr/lib/pear');
// 或使用 ini_set
ini_set('include_path', '/usr/lib/pear');
?>
示例 #2 添加到include path
利用常量 PATH_SEPARATOR
可跨平台扩展 include path。
这个示例中我们把 /usr/lib/pear 添加到了
现有的 include_path
的尾部。
<?php
$path = '/usr/lib/pear';
set_include_path(get_include_path() . PATH_SEPARATOR . $path);
?>
参见
- ini_set() - 为一个配置选项设置值
- get_include_path() - 获取当前的 include_path 配置选项
- restore_include_path() - 还原 include_path 配置选项的值
- include - include
+添加备注
用户贡献的备注 1 note
parks at vecinc dot com ¶
15 years ago
If you find that this function is failing for you, and you're not sure why, you may have set your php include path in your sites's conf file in Apache (this may be true of .htaccess as well)
So to get it to work, comment out any "php_value include_path" type lines in your Apache conf file, and you should be able to set it now in your php code.
备份地址:http://www.lvesu.com/blog/php/function.set-include-path.php