(PHP):警告:include_once,无法打开流:权限被拒绝

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11374874/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 00:22:27  来源:igfitidea点击:

(PHP): Warning: include_once, failed to open stream: Permission denied

phpmysqlxampp

提问by Howaida Khoureieh

Im learning how to write a Sign Up pageusing Php and Mysql (XAMPP).

我正在学习如何使用 Php 和 Mysql (XAMPP)编写注册页面

Now, I downloaded the source code in this website:

现在,我在这个网站下载了源代码:

http://net.tutsplus.com/tutorials/php/create-a-signup-form-with-email-confirmation/

http://net.tutsplus.com/tutorials/php/create-a-signup-form-with-email-confirmation/

and tried to make sure it works. But when openning:

并试图确保它有效。但是打开的时候:

 http://localhost/source/index.php

I got the following warnings:

我收到以下警告:

Warning: include_once(C:\xampp\htdocs\source\inc\php\config.php) [function.include-once]: failed to open stream: Permission denied in C:\xampp\htdocs\source\index.php on line 3

Warning: include_once() [function.include]: Failed opening 'inc/php/config.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\source\index.php on line 3

Warning: include_once(C:\xampp\htdocs\source\inc\php\functions.php) [function.include-once]: failed to open stream: Permission denied in C:\xampp\htdocs\source\index.php on line 4

Warning: include_once() [function.include]: Failed opening 'inc/php/functions.php' for inclusion (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\source\index.php on line 4

Here are the lines where I got the warnings:

以下是我收到警告的行:

<?php

include_once 'inc/php/config.php';
include_once 'inc/php/functions.php';
.
.

Any Help?

任何帮助?

回答by Yang

Replace this:

替换这个:

include_once 'inc/php/config.php';
include_once 'inc/php/functions.php';

with

include_once dirname(__FILE__) . '/inc/php/config.php';
include_once dirname(__FILE__) . '/inc/php/functions.php';

回答by Tom Walters

Much of the time using full paths like that is disabled in PHP for security reasons, try changing the paths in your include statements to being relative.

大多数情况下,出于安全原因,PHP 中禁用了像这样的完整路径,请尝试将包含语句中的路径更改为相对路径。