0

フォルダにあるページをロードすると、ページに含まれているドキュメントをロードしようとするとエラーが発生します。

 <?php
include ('Resources/core/init.php');
include ('Resources/includes/header.php');
include ('Resources/includes/head.php');
include ('Resources/includes/footer.php');
 ?>

Web サイトのコンテナー フォルダーにないインデックス ページで使用すると、正常に動作します。たとえば、インデックス ページのルートは: ですwebsitename/index.phpが、他のページは次のようなフォルダーにありますwebsitename/pages/aboutus/contactus.php。これらはウェブサイトのページの正確な名前ではなく、単なる例です。これについて私に何ができるか知っている人はいますか?

4

3 に答える 3

0

if you want to keep using relative paths you need to use the double dot to jump back a level, for example if its 2 folders deep you would use

<?php
    include ('../../Resources/core/init.php');
    include ('../../Resources/includes/header.php');
    include ('../../Resources/includes/head.php');
    include ('../../Resources/includes/footer.php');
?>

but of course you should listen to others and create an absolute path constant and prepend it to the path if you're using multiple file locations on an app that loads the same files relative, its going to be a pain

于 2013-05-25T14:50:52.183 に答える
0

常に絶対パスを使用してください。少なくとも

include $_SERVER['DOCUMENT_ROOT'].'Resources/core/init.php';
于 2013-05-25T14:34:42.477 に答える