【发布时间】:2015-01-20 07:39:24
【问题描述】:
好的,这是我的项目结构(简化):
+blog
-index.php //Index 2
+ views
-index.php // Index 3
-article.php
-index.php // Index 1
+partials
-constants.php
-top.php
好的,所以在 Index 1 和 Index 2 我使用这行代码来包含一些部分/sn-ps:
索引 1:
<?php require_once("./partials/constants.php"); ?>
<?php require_once("./partials/top.php"); ?>
索引 2:
<?php require_once("../partials/constants.php"); ?>
<?php require_once("../partials/top.php"); ?>
但在 Index 3 如果我使用这个:
<?php require_once(".../partials/constants.php"); ?>
<?php require_once(".../partials/top.php"); ?>
我收到此错误:
<body><br>
<b>Warning</b>: require_once(.../partials/constants.php): failed to open stream: No such file or directory in <b>/home/codio/workspace/blog/views/index.php</b> on line <b>1</b><br>
<br>
<b>Fatal error</b>: require_once(): Failed opening required '.../partials/constants.php' (include_path='.:/home/codio/.parts/packages/php5-apache2/5.5.15/lib/php') in <b>/home/codio/workspace/blog/views/index.php</b> on line <b>1</b><br>
</body>
【问题讨论】:
标签: php directory structure require relative-path