WebDesign:头文件,但有自定义页面标题? [英] WebDesign: Header file, but with custom Page titles?

查看:155
本文介绍了WebDesign:头文件,但有自定义页面标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用标题为网站创建模板。
调试起来很简单,而且非常方便。



我现在面临的问题是使用head BUT和自定义页面标题。
如果这是我的 header.php >

 < html> 
< head>
< title>我的网站 : ??? < / HTML>
< / head>
< body>


< / body>
< / html>

我需要?每个页面都要被替换。



这可能吗?如果是这样,怎么样?谢谢。 :)

解决方案

不知道更多关于您的文件包含方案,最简单的方法是:

page2.php

 <?php 
$ pageTitle ='Page 2';
包含'header.php';
?>

< div>我的内容< / div>

<?php include'footer.php'; ?>

header.php

 < HTML> 
< head>
< title>我的网站:<?php echo $ pageTitle?> < /标题>
< / head>
< body>

footer.php

 < /体> 
< / html>


I've been using headers to create templates for websites. It's easy, and very convenient for debugging.

I now face the problem of using head BUT with custom page titles. If this is my header.php >

<html>
    <head>
        <title> My Site : ??? </html>
    </head>
<body>


</body>
</html>

I need ??? to be replaced for every page.

Is this possible? If so, how? Thank you. : )

解决方案

Not knowing more about your file inclusion scheme, the simplest way would be:

page2.php

<?php
$pageTitle = 'Page 2';
include 'header.php';
?>

<div>My content</div>

<?php include 'footer.php'; ?>

header.php

<html>
    <head>
        <title> My Site : <?php echo $pageTitle ?> </title>
    </head>
<body>

footer.php

</body>
</html>

这篇关于WebDesign:头文件,但有自定义页面标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆