Php 继承-在包含的文件中包含文件
我有三个文件:Php 继承-在包含的文件中包含文件,php,inheritance,Php,Inheritance,我有三个文件: blog.php comment.php function.php 在我的blog.php中,function.php和comment.php有一个include() 我的问题是:comment.php是否可以从blog.php继承function.php的include,并在不再次声明include()函数的情况下使用其内容 提前感谢您的帮助。如果首先包含function.php,则任何运行在comment.php中的代码都可以使用它 但是,如果comment.php要求f
- blog.php
- comment.php
- function.php
提前感谢您的帮助。如果首先包含function.php,则任何运行在comment.php中的代码都可以使用它
但是,如果comment.php要求function.php正确运行,则在comment.php顶部放置一个
include\u once
每次包含文件时,包含的文件都会在包含之前继承所有代码。如果您包括以下内容:
a.php
$bar = "foo";
include('a.php');
echo $foobar;
b.php
$bar = "foo";
include('a.php');
echo $foobar;
c.php
$bar = "foo";
include('a.php');
echo $foobar;
d.php
$bar = "foo";
include('a.php');
echo $foobar;
希望这能有所帮助。php的include基本上是一个剪切粘贴的东西,好像要包含的文件的内容实际上是执行include操作的文件的一部分。实际上帮助了我。谢谢