Php 从外部文件添加include

Php 从外部文件添加include,php,Php,我想从我尝试过的名为sitename.php的文件中包含一个站点名称 $thisPage='include "sitename.php" '; ?> 并获取错误报告。我还需要将该文件添加到 include("../../../EngineerLocation/sitename.php"); 我想从php文件中包含sitename,而不是sitename,请尝试: include("$_SERVER[DOCUMENT_ROOT]/sitename.php"); 您可以包括一个实际的p

我想从我尝试过的名为sitename.php的文件中包含一个站点名称

$thisPage='include "sitename.php" '; ?>
并获取错误报告。我还需要将该文件添加到

 include("../../../EngineerLocation/sitename.php");
我想从php文件中包含sitename,而不是sitename,请尝试:

include("$_SERVER[DOCUMENT_ROOT]/sitename.php");

您可以包括一个实际的php文件:

// sitename.php
<?php
$thisPage = "Page Name";

// otherpage.php
<?php
include("sitename.php");
echo $thisPage;
//sitename.php

站点名称如何存储在sitename.php中?sitename.php仅包含单词country printThis,但它仅在页面顶部显示文件获取内容(sitename.php),这看起来很合理,但第一个显示没有显示任何内容,第二个显示word报告,表明该文件未找到。抱歉,我的错误,文件名必须在引号内:
做得好,很好,非常感谢。你知道如何通过包含sitename.php来添加country Print这个词吗?这太棒了,谢谢你。这将节省大量的时间来添加新帐户。但这又如何适应
// sitename.txt
Page Name
// otherpage.php
<?php
$thisPage = file_get_contents("sitename.txt");
<?php
$thisPage = file_get_contents("sitename.txt");
include("../../../EngineerLocation/{$thisPage}.php");