【发布时间】:2013-05-08 17:00:22
【问题描述】:
大家好,我有一个用 codeigniter 开发的网站,我想将一些我在许多页面中使用的 javascript/PHP 函数存储到一个名为 common.php 的文件中。 我试过这种模式:
require(base_url().'application/libraries/common.php'); //I have tried also include
这会返回这个错误:
A PHP Error was encountered
Severity: Warning
Message: require() [function.require]: http:// wrapper is disabled in the server configuration by allow_url_include=0
我要去我的 php.ini 并打开 allow_url_include,重新启动 apache,当我尝试加载页面时,现在返回这个错误:
A PHP Error was encountered
Severity: Warning
Message: require() [function.require]: http:// wrapper is disabled in the server configuration by allow_url_include=0
Filename: backend/hotel_view.php
Line Number: 6
A PHP Error was encountered
Severity: Warning
Message: require(http://demo.webanddesign.it/public/klikkahotel.com/application/libraries/common.php) [function.require]: failed to open stream: no suitable wrapper could be found
Filename: backend/hotel_view.php
Line Number: 6
Fatal error: require() [function.require]: Failed opening required 'http://demo.webanddesign.it/public/klikkahotel.com/application/libraries/common.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/public/klikkahotel.com/application/views/backend/hotel_view.php on line 6
如何在我的页面中包含一个简单的文件?
【问题讨论】:
-
下面给出了这么多的答案,但它取决于你的公共文件的大小是要制作辅助函数还是直接查看。但根据我的说法,你应该始终保持 js 和 php 不同良好做法的文件!
标签: php codeigniter