require_once()[function.request]:打开失败,需要


require_once() [function.require]: Failed opening required

我一直在为这个项目寻找解决方案,但似乎什么都不适合我,因为我已经在其他具有相同库(PHPExcel)的项目中使用了require_once,并且运行得很好,但现在我不知道出了什么问题。

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

$this->load->library('PHPExcel');
require_once (base_url().'applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php');

并显示:

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问题。

尝试以正确的方式使用代码点火器。

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


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

$autoload['libraries'] = array('my_library');


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

<?php
class Something extends MY_Controller
{
    public function __construct()
   {
        parent::__construct();
        $this->load->library('my_library');
   }
   public function my_function()
   {
        ...
   }
}

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

您不能使用

base_url();

你可以使用

APPPATH

它是恒定的

   require_once(APPPATH.'applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php');