我已经为这个问题寻找了一个解决方案,但似乎没有什么对我有效,协议是,我已经在其他项目中使用过require_once和同一个库(PHPExcel),并且工作得很好,但现在我不知道出了什么问题。
我在这两个项目中都使用了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问题。
发布于 2014-04-26 17:55:48
试着正确地使用代码点火器。
建议:,因为它是一个库,所以不必精确地包含它。把库文件移到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()
{
...
}
}发布于 2014-04-26 17:50:35
您试图通过HTTP require文件,但连接失败。您应该尽可能使用磁盘路径来require文件。
发布于 2014-04-26 17:52:57
你不能用
base_url();您可以使用
APPPATH它是不变的
require_once(APPPATH.'applications/proyect/libraries/PHPExcel/Cell/AdvancedValueBinder.php');https://stackoverflow.com/questions/23314527
复制相似问题