0

異なるディレクトリ レベルの 2 つのファイルが同時に同じファイルを呼び出しています。

// index.php
include('./include/same_file.php');

// Webpages/page1.php
include('../include/same_file.php');

// include/same_file.php
include('../template/header.php'); // failed to open on index.php
fopen('../files/text1.txt');       // failed to open on index.php
file('./files/AA.html');           // failed to open on /include/same_file.php

私は何時間も解決策を探してみましたが、dirname(__FILE__)$_SERVER[DOCUMENT_ROOT]解決策を見つけましたが、私のような初心者に詳細な教えを与えていないため、どれも機能しません。

4

1 に答える 1

1

これを試して..

require_once(__DIR__."/include/same_file.php");

また

include(__DIR__."/include/same_file.php");
于 2013-12-11T07:27:52.843 に答える