[英]Relative or Absolute path not opening
我很难理解php中相对路径的过程。 我正在使用WAMP和在Google等上花费数小时后尝试过的所有东西来工作本地主机,只是错误。 错误的范围从“无法打开流:没有此类文件或目录”到堆栈错误。 我也尝试过绝对路径,但结果仍然相同。 我对如何进行不知所措,因此可以真正使用一些帮助。 我已经附上了我尝试过的程序清单,任何建议都将受到欢迎。 非常感谢
In the admin header file:
<?php require_once('./Connections/connect.php'); ?>
<?php require_once('../../../Connections/connect.php'); ?>
<?php require_once('C:\wamp\www\domain/Connections/connect.php'); ?>
localhost\domain > root > index.php
header.php
footer.php
Connections\connect.php
localhost\domain\admin > index.php
header.php
footer.php
form-inc.php
localhost\domain\admin\cp\users > index.php <--Users control panel in which I need to call
header.php & footer.php from the admin
directory which is where I am having the
problem.
PHP 5.3
WAMP
尝试这样做以避免歧义dirname(__FILE__)
要么
如果您使用的是PHP 5.3或更高版本,请使用__DIR__
> __DIR__
。
用法-
require dirname(__FILE__) . '/../../filename.php';
要么 -
require __DIR__ . '/../../../filename.php';
手册中的更多内容-http: //php.net/manual/zh/language.constants.predefined.php
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.