如何在php中追溯链接包含多个头文件

如何在php中追溯链接包含多个头文件

问题描述:

This is what I'm trying to figure out.

Why does chain include or require work up one level, but not two?

In other words if I write the following at the very beginning of index.php:

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

That works. ...but, if I go one step further and ALSO write the following at the beginning of header.php:

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

What happens then is the application only renders up to header.php. Why does it not render html_header.php?

Hope this is clear enough for future references. I would also like to know if there is anyway of achieving this type of chaining especially when relating to the headers. Thank you.

这就是我想弄清楚的。 p>

> p>

换句话说,如果我在index.php的最开头写下以下内容:

 &lt;?php include(“header.php”);  ?&gt; 
  code>  pre> 
 
 

这有效。 ...但是,如果我更进一步,并在header.php的开头写下以下内容: p>

 &lt;?php include(“html_header.php”)  ;  ?&gt; 
  code>  pre> 
 
 

然后,应用程序只会渲染到header.php。 为什么它不呈现html_header.php? p>

希望这对于将来的引用是足够清楚的。 我还想知道是否有任何实现这种类型的链接,尤其是在与标题相关时。 谢谢。 p> div>

Wow! I feel like such an idiot. First of all, I was missing a quotation mark(?). In header.php I had <php require("html_header.php") ?> which is why it wasn't working but even if that hadn't worked, all I really needed to do was place both the include of header.php and the require of html_header.php together in index.php instead of separate on each file. Why I tried to do it the other way, I have no idea, but this was a real brain fart. Thanks anyways @David Kuna.