php PHP访问路径

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28386763/
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 23:50:10  来源:igfitidea点击:

PHP access path

phpapache

提问by Диян Богданов

I configigurate 'htdocs' to be localhost/Workspace/ in httpd.conf. When i go to url localhost/index.php everything is okey, but when i am trying to connect to localhost/_members/register i get the following problem.

我在 httpd.conf 中将 'htdocs' 配置为 localhost/Workspace/。当我转到 url localhost/index.php 时,一切正常,但是当我尝试连接到 localhost/_members/register 时,出现以下问题。

Warning: require_once(core/init.php): failed to open stream: No such file or directory in C:\xampp\htdocs\Workspace_members\register.php on line 2 Fatal error: require_once(): Failed opening required 'core/init.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\Workspace_members\register.php on line 2

警告:require_once(core/init.php): 无法打开流:第 2 行 C:\xampp\htdocs\Workspace_members\register.php 中没有这样的文件或目录致命错误:require_once(): 无法打开所需的 'core/第 2 行的 C:\xampp\htdocs\Workspace_members\register.php 中的 init.php' (include_path='.;C:\xampp\php\PEAR')

When i remove the files form 'Workspace/_members' and move them to 'Workspace' directory, everything is working. You can see my code HERE.

当我从“Workspace/_members”中删除文件并将它们移动到“Workspace”目录时,一切正常。你可以在这里看到我的代码。

If you have any suggestions please help me. :)

如果您有任何建议,请帮助我。:)

回答by felipsmartins

On your index.phpyou could try it out:

在您的index.php 上,您可以尝试一下:

<?php

$rootpath =  dirname(__FILE__);
set_include_path(get_include_path() . PATH_SEPARATOR . $rootpath);

include 'header.php';
include 'footer.php';

Also: rename core/Init.phpto core/init.php;
No there's any functions/functions.php(referenced on core/init.php line 26);

另外:将core/Init.php重命名为 core/init.php;
没有任何functions/functions.php(在core/init.php第26行引用);

回答by kellanburket

Your 'core' directory is one directory above your '_members' directory. Try require_once('../core/init.php').

您的“核心”目录是“_members”目录上方的一个目录。试试require_once('../core/init.php')