Php我想从另一个包含文件中删除包含的文件

Php我想从另一个包含文件中删除包含的文件,php,include,Php,Include,我想从另一个包含文件中删除包含的文件 file1.php: <?php include("file2.php"); ?> file2.php: <?php include("anotherfile.php"); ?> 我不想包含另一个file.php,但我只想 file2.php请帮助我您可以让第二个包含条件 File1.php $includesAnotherFile = false; include("file2.php"); File2.php if (!i

我想从另一个包含文件中删除包含的文件

file1.php:

<?php
 include("file2.php");
?>
file2.php:

<?php
include("anotherfile.php");
?>
我不想包含另一个file.php,但我只想
file2.php请帮助我

您可以让第二个包含条件

File1.php

$includesAnotherFile = false;
include("file2.php");
File2.php

if (!isset($includesAnotherFile ) || $includesAnotherFile)
{
    include("anotherfile.php");
}

你试过。。。从file2.php文件中删除include?那么您应该从file2.phpi中删除另一个file.php。我不想从文件中删除,因为其他文件可以使用此功能。如果不需要,请检查该文件是否不包含。这还不清楚您真正想要实现的目标。请编辑您的帖子并更具体一点。是否可以将文件从一行添加到另一行?不,include file.php包含整个file.php。如果您只想包含一个文件的一部分,您应该考虑将您的文件拆分为几个其他文件。