php使用 set_include_path

通过set_include_path引用home/lib/image.func.php

1.创建include.php

2.添加如下代码

3.在需要引用的文件中包含include.php文件

<?php
session_start();
define("ROOT",  dirname(__FILE__));
set_include_path(".".PATH_SEPARATOR.ROOT."/lib".PATH_SEPARATOR.ROOT."/core".PATH_SEPARATOR.get_include_path());
 require_once‘mysql.func.php‘;
require_once‘image.func.php‘;
require_once‘common.func.php‘;
 require_once‘image.func.php‘;
?>

  

包含inclde.php 文件后无法正常运行

原因是因为两次使用了session_start();

时间: 2024-08-26 22:56:48

php使用 set_include_path的相关文章

set_include_path get_include_path

set_include_path("123/"); get_include_path — 获取当前的 include_path 配置选项 string get_include_path ( void ) function initialize() { set_include_path(get_include_path().PATH_SEPARATOR . "core/"); set_include_path(get_include_path().PATH_SEPAR

php set_include_path

string set_include_path ( string $new_include_path ) 为当前脚本设置 include_path 运行时的配置选项. Example #2 添加到include path 利用常量 PATH_SEPARATOR 可跨平台扩展 include path. 这个例子中我们把 /usr/lib/pear 添加到了 现有的 include_path 的尾部. <?php$path = '/usr/lib/pear';set_include_path(ge

PHP中使用set_include_path动态设置文件加载扫描路径

/index.php/include/config.php 下面是index.php <?php  $path = '/usr/lib/pear';  set_include_path(get_include_path() . PATH_SEPARATOR . $path); //设置后的include_path变为类似/usr/lib/function;/usr/lib/pear  include("config.php"); //先搜索当前目录->搜索get_inclu

set_include_path() &amp;&amp;get_include_path()用法

function initialize(){    set_include_path(get_include_path().PATH_SEPARATOR . "core/");    set_include_path(get_include_path().PATH_SEPARATOR . "app/");    set_include_path(get_include_path().PATH_SEPARATOR . "admin/");    s

set_include_path和get_include_path用法详解

今天在公司研习源码时,看到了set_include_path(dirname(__FILE__));这样一行代码,甚为不解.于是我就百度了一下,顺便看了一下php.net的手册,可是还是不太明白它到底有什么作用.   偶然见看到一段另外一段代码,然后突发灵感,测试了一下,果然不出所料!   现在我总结一下吧:   首先set_include_path这个函数呢,是在脚本里动态地对PHP.ini中include_path进行修改的.而这个include_path呢,它可以针对下面的include和

set_include_path详细解释(转)

首先我们来看这个全局变量:__FILE__它表示文件的完整路径(当然包括文件名在内)也就是说它根据你文件所在的目录不同,有着不同的值:当然,当它用在包行文件中的时候,它的值是包含的路径: 然后:我们看这个函数:string dirname ( string path )它是PHP内置函数,它的作用是什么呢,就是返回除了本文件名以外的所在目录,给你举个例子假如你的首页中用到了_FILE_这个变量:(假设你的网页所在目录为:http://localhost/web/index.php),那么:_FI

set_include_path()的用法

朋友们 开发的时候 ,总会 遇到 include_once()的情况.有时候,我们需要大量的引用文件,但是被引用文件的路径有时候是个问题.  我们可以把 经常要引用 的文件,放在一个 文件夹中,我们取名为include,这样 我们 就把 该文件夹 当做 默认的引用路径. 我们可以 用 set_include_path() 来设定,多个路径 可以用 路径分隔符分开(windows为';',linux为':'). 例: define('INCLUDE_PATH','/include/'); set_

php get_include_path();是干嘛的、??还有set_include_path();/?????

首先 我们来看这个全局变量:__FILE__ 它表示文件的完整路径(当然包括文件名在内) 也就是说它根据你文件所在的目录不同,有着不同的值:当然,当它用在包行文件中的时候,它的值是包含的路径: 然后: 我们看这个函数: string dirname ( string path ) 它是PHP内置函数,它的作用是什么呢,就是返回除了本文件名以外的所在目录,给你举个例子 假如你的首页中用到了_FILE_这个变量: (假设你的网页所在目录为:),那么: _FILE_的值为(一个绝对路径).而此时dir

16)PHP, set_include_path

代码展示: 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh-cn"> 3 <head