localhost环境中的链路径解决方案:http://在服务器配置中通过allow_url_include = 0禁用包装器

时间:2014-07-10 12:32:21

标签: php localhost absolute-path

我已经看过很多次问过这个问题了,但我似乎无法为自己找到解决方案

这是我的基本文件夹结构:

http://localhost/cms/

要获取我的所有代码,我在此处有一个实用程序文件:

http://localhost/cms/includes/utilities.inc.php

并且在该文件中我有requires()来包含类,如下:

require('classes/Post.php');
require('classes/User.php');
require('classes/Comments.php');
require('classes/Category.php');

当我尝试将我的http://localhost/cms/includes/utilities.inc.php文件包含在以下目录中时,它不起作用! http://localhost/cms/admin/

当我尝试时,我收到此错误:

Warning: require(classes/Post.php): failed to open stream: No such file or directory in C:\xampp\htdocs\cms\includes\utilities.inc.php on line 12

Fatal error: require(): Failed opening required 'classes/Post.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\cms\includes\utilities.inc.php on line 12

在我的实用程序文件中使用绝对路径时:

require('http://localhost/cms/classes/Post.php');
require('http://localhost/cms/classes/User.php');
require('http://localhost/cms/classes/Comments.php');
require('http://localhost/cms/classes/Category.php');

我收到以下错误:

Warning: require(): http:// wrapper is disabled in the server configuration by allow_url_include=0 in C:\xampp\htdocs\cms\includes\utilities.inc.php on line 12

Warning: require(http://localhost/cms/classes/Post.php): failed to open stream: no suitable wrapper could be found in C:\xampp\htdocs\cms\includes\utilities.inc.php on line 12

Fatal error: require(): Failed opening required 'http://localhost/cms/classes/Post.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\cms\includes\utilities.inc.php on line 12

如何才能获得一个能够正确链接的系统(最好不要与PEAR相关)?

0 个答案:

没有答案