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

Php i want to remove included file form another include file

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

file1.php:

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

file2.php:

<?php
include("anotherfile.php");
?>

我不想包括 anotherfile.php 但我只想 file2.php请帮帮我

您可以使第二个包含条件

File1.php

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

File2.php

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