【发布时间】:2012-10-16 19:33:48
【问题描述】:
我有一堆目录,但在包含一些文件时遇到了麻烦。这是我的结构。
index.php
vian/vian.php
包括/整体/head_content.php
包括/overall/head.php
这是我的head_content.php。
testing text
<?php include 'includes/overall/head.php'; ?>
<div class="wrapper row3">
<div id="container" class="clear">
<div id="content">
我想将该文件包含在vian/vian.php中
我使用'../includes/overall/head_content.php';,自从出现“测试文本”后,路径就可以正常工作。但它不能包含includes/overall/head.php。我隐约明白为什么它不起作用,但我不知道如何解决它。
'../includes/overall/head_content.php'; 用于我的所有页面,包括位于我的根目录中的index.php。
【问题讨论】:
-
查看
__DIR__magic constant。然后,您可以包含相对于当前文件目录的:__DIR__ . '/../vian/vian.php'等。
标签: php include relative-path