当前位置: 移动技术网 > IT编程>开发语言>PHP > [日常] PHP设置 include_path 配置选项

[日常] PHP设置 include_path 配置选项

2018年03月07日  | 移动技术网IT编程  | 我要评论

动态设置php.ini中的include_path 配置选项:

两种方式
set_include_path($new_include_path)
ini_set('include_path',$new_include_path);
利用常量 PATH_SEPARATOR 可跨平台扩展 include path,可以把自己设置的path加在现有include_path的尾部

 

<?php
$path='/var/www/html';
//第一种
//set_include_path(get_include_path() . PATH_SEPARATOR . $path);

//第二种
ini_set('include_path', ini_get('include_path'). PATH_SEPARATOR.$path);
require 'test2.php';

var_dump($a);

 

在/var/www/html下建立test2.php

<?php
$a="hello world";

  

结果

  

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网