PHP 访问路径

PHP access path

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

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

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

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

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

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

<?php

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

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

还有: 将 core/Init.php 重命名为 core/init.php;
没有 functions/functions.php(参考 core/init.php 第 26 行);