Header how to modify title of the page “on the fly”

删除回忆录丶 提交于 2019-12-12 17:14:51

问题


My header is called as you can imagine, on each pages.

it means that on each pages i've the same title (bad for SEO)

Is there a workaround to set pages title outside the header.php ?

Thanks


回答1:


Make a variable $page_title. Set it before including the header and in the header have something like:

echo("<title>$page_title</title>");



回答2:


Set a variable for the title before including the header, then output the variable within the header.




回答3:


include ('includes/header.php');
titleAndMeta('yourTitle');

This goes in your page and this goes in your header.php

function titleAndMeta($title)
 echo '<title>$title</title>';


来源:https://stackoverflow.com/questions/2825776/header-how-to-modify-title-of-the-page-on-the-fly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!