是否可以在PHP中包含/要求包含部分代码的文件?

是否可以在PHP中包含/要求包含部分代码的文件?,php,Php,我想知道是否有可能在PHP中包含部分文本文件作为代码而不是文本 例如: **Index.php FILE** <?php require "part1.php"; ?> <div>HELLO WORKD</div> <?php require "part2.php"; ?> **Part1.php FILE:** <?php if(0==0) { P

我想知道是否有可能在PHP中包含部分文本文件作为代码而不是文本

例如:

**Index.php FILE**
    <?php
    require "part1.php";
    ?>

    <div>HELLO WORKD</div>

    <?php
    require "part2.php";
    ?>


**Part1.php FILE:**

    <?php
    if(0==0) {
      Part2.php FILE:
    }
    ?>


Part2.php FILE
<?php
}
?>
**Index.php文件**
你好,沃克
**Part1.php文件:**
Part2.php文件

绝对正确。require、require_once、include和include_once是您的朋友,可以启用此功能。这里有更多关于每个






当然可以,但包含/要求的页面可以访问包含/要求之前编写的index.php文件var,而不是包含/要求之后编写的index.php文件var,但当我使用“包含”进行操作时,只要每个文件中的php代码不完整,我就只能得到纯文本!请记住,“IF”语句分为两个文件!