首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >require_once() [function.require]:需要打开失败

require_once() [function.require]:需要打开失败
EN

Stack Overflow用户
提问于 2014-04-26 17:47:00
回答 3查看 3.3K关注 0票数 0

我已经为这个问题寻找了一个解决方案,但似乎没有什么对我有效,协议是,我已经在其他项目中使用过require_once和同一个库(PHPExcel),并且工作得很好,但现在我不知道出了什么问题。

我在这两个项目中都使用了CodeIgniter,但我不知道这是PHP问题还是我做错了什么。下面是代码:

代码语言:javascript
复制
$this->load->library('PHPExcel');
require_once (base_url().'applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php');

这里展示的是:

代码语言:javascript
复制
A PHP Error was encountered

Severity: Warning

Message: Users::require_once(http://localhost/my_proyect/applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php) [function.Usuarios-require-once]: failed to open stream: 
An error occurred during the connection attempt because the connected party did not properly respond after a period of time, or there was an error in the connection established because connected host has failed to respond

Fatal error: Users::require_once() [function.require]: 
Failed opening required 'http://localhost/my_proyect/applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php' (include_path='.;C:\php5\pear'

我不知道C:\php5\pear是怎么回事,但我不能处理这个require_once问题。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-04-26 17:55:48

试着正确地使用代码点火器。

建议:,因为它是一个库,所以不必精确地包含它。把库文件移到applications/libraries目录下-

1)您可以在config/autoload.php中自动加载它

代码语言:javascript
复制
$autoload['libraries'] = array('my_library');

2)或者您可以将所需的控制器专门加载到

代码语言:javascript
复制
<?php
class Something extends MY_Controller
{
    public function __construct()
   {
        parent::__construct();
        $this->load->library('my_library');
   }

   public function my_function()
   {
        ...
   }
}
票数 0
EN

Stack Overflow用户

发布于 2014-04-26 17:50:35

您试图通过HTTP require文件,但连接失败。您应该尽可能使用磁盘路径来require文件。

票数 0
EN

Stack Overflow用户

发布于 2014-04-26 17:52:57

你不能用

代码语言:javascript
复制
base_url();

您可以使用

代码语言:javascript
复制
APPPATH

它是不变的

代码语言:javascript
复制
   require_once(APPPATH.'applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php');
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23314527

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档