简体   繁体   English

动态页面标题无法正确显示

[英]dynamic page title not displaying correctly

I am trying to dynamically change my page titles. 我正在尝试动态更改我的页面标题。 I have the following script inside my header.php page 我在header.php页面中有以下脚本

<?php $pagetitle = "Website Home"; ?>
<head>  
<title><?php echo $pagetitle ?></title>  
</head>

But instead of my page title displaying as "Website Home", the page title shows up as " <?php echo $pagetitle ?> ". 但是,不是我的页面标题显示为“网站主页”,页面标题显示为“ <?php echo $pagetitle ?> ”。 Is there a reason why the php will not execute inside the <title> tags? 有没有理由为什么php不会在<title>标签内执行?

you're calling your header.php some unusual way. 你正在以一种不寻常的方式调用header.php。 Just include it in other php script. 只需includeinclude在其他PHP脚本中即可。

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

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