PHP:set_include_path和require_once():需要打开失败

时间:2013-04-12 10:54:15

标签: php path include set

我的php设置出了问题,我知道肯定'因为完全相同的lib对我在HIS服务器上的合作伙伴来说非常有效。

$inc_path = get_include_path();
$inc_path .= PATH_SEPARATOR . "./rtmp" . PATH_SEPARATOR . "./SabreAMF";
set_include_path($inc_path);

require_once 'rtmp/SabreAMF/OutputStream.php';
require_once 'rtmp/SabreAMF/InputStream.php';
require_once 'rtmp/SabreAMF/AMF0/Serializer.php';
require_once 'rtmp/SabreAMF/AMF0/Deserializer.php';
require_once 'rtmp/SabreAMF/TypedObject.php';

这就是我得到的

Warning: require_once(rtmp/SabreAMF/OutputStream.php): failed to open stream: No such file or directory in C:\Program Files (x86)\EasyPHP-12.1\www\phpLoL-master\rtmp\RtmpClient.php on line 7

Fatal error: require_once(): Failed opening required 'rtmp/SabreAMF/OutputStream.php' (include_path='.;C:\php\pear;./rtmp;./rtmp/SabreAMF;./rtmp;./SabreAMF') in C:\Program Files (x86)\EasyPHP-12.1\www\phpLoL-master\rtmp\RtmpClient.php on line 7

3 个答案:

答案 0 :(得分:1)

更新到php 5.4解决了这个问题。

答案 1 :(得分:0)

尝试

$inc_path = $_SERVER['DOCUMENT_ROOT'];    
require_once $inc_path.'/rtmp/SabreAMF/OutputStream.php';    
require_once $inc_path.'/rtmp/SabreAMF/InputStream.php';    
require_once $inc_path.'/rtmp/SabreAMF/AMF0/Serializer.php';    
require_once $inc_path.'/rtmp/SabreAMF/AMF0/Deserializer.php';    
require_once $inc_path.'/rtmp/SabreAMF/TypedObject.php';

答案 2 :(得分:0)

实际上你正在设置包含路径

已经喜欢这个

$inc_path .= PATH_SEPARATOR . "./rtmp" . PATH_SEPARATOR . "./SabreAMF";
set_include_path($inc_path); 

由于现在PHP知道您所包含的文件可能在此路径中,您可以包含如下

require_once 'OutputStream.php';

require_once 'AMF0/Deserializer.php';
  

注意: - 我假设你正在做你的set_include_path   应用程序引导,其他明智的方法包括路径   在语法上根本不会工作