[英]I am getting Permission denied error when i use require_once() with ampps
I am using require_once
to call a function into index.php
from Category.class.php
but i am getting this error:我正在使用require_once
将 function 调用到index.php
中的Category.class.php
但是这个错误
Warning: require_once(C:\Program Files\Ampps\www\admin-panel): failed to open stream: Permission denied in C:\Program Files\Ampps\www\admin-panel\admin-dashboard\Category.class.php on line 22
Fatal error: require_once(): Failed opening required '' (include_path='.;C:\php\pear') in C:\Program Files\Ampps\www\admin-panel\admin-dashboard\Category.class.php on line 22
This is the function i am trying to call:这是我试图调用的 function:
public function index()
{
$db = new DataBase();
$categories = $db->select("SELECT * FROM `categories` ORDER BY `id` DESC;");
require_once(realpath(dirname(__FILE__) . "../template/admin/category/index.php"));
}
And this is the .htaccess
file:这是.htaccess
文件:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.+)$ admin-panel/index.php [QSA,L]
How can i solve this?我该如何解决这个问题?
I found the solution, The problem was the syntax error:我找到了解决方案,问题是语法错误:
I wrote require_once
like this which is incorrect:我这样写require_once
这是不正确的:
require_once(realpath(dirname(__FILE__) . "../template/admin/category/index.php"));
When i change it to following code problem was solved:当我将其更改为以下代码时,问题已解决:
require_once(realpath(dirname(__FILE__) . "/../template/admin/categories/index.php"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.