繁体   English   中英

php如何包含没有标题的页面

[英]php how to include page without header

我想在我的页面顶部包含一个页面。

但是当我这样做的时候。 我的页眉被替换为页眉。

例如,我的标题替换为页面标题。

我该如何解决?

包含的页眉:

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>Retrieving video details</title>
<style>
img {
  padding: 2px; 
  margin-bottom: 15px;
  border: solid 1px silver; 
}
td {
  vertical-align: top;
}
</style>
  </head>

您最好的选择是删除该页面的标题,以便它不会覆盖您的标题,或者在加载包含的文件后设置您的标题以使您的标题覆盖所包含页面的标题。 如果您从另一个域外部获取它,恐怕您会被卡住。

编辑如果可以,从包含的页面的源代码中删除<title>标签。 否则,包含该文件并在其后设置<title>Your Title</title>

对于这个问题,我有一个对我有用的解决方案。

  1. 创建一个页面并在该页面内创建一个函数

     <?php function createHeader($title,$desc1,$keywords) { ?> <!DOCTYPE html> <html lang="zxx"> <head> <title>.....</title> <link>--------</link> ----------------------- </head>
  2. 调用这个函数。 例如

    <?php //I include this page in my another page that's why i write this condition if($news!="tech-headlines"){ include'header.php'; // include header file in this page createHeader(); // call header function } ?>
  3. 在正文中编写您的代码

    <body> ------------- ------------- </body>
  4. 此页面我已包含在另一个页面中,不包括标题(仅在正文代码中访问)或当我单独运行此页面时,它会运行包括标题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM