Php 在<;之后设置页面标题;头>;标签
我有单页没有页眉/页脚。它们只包含中每个页面的内容 我的index.php页面有包含页面标题的模板,但我想在每个页面中设置每个页面标题Php 在<;之后设置页面标题;头>;标签,php,html,Php,Html,我有单页没有页眉/页脚。它们只包含中每个页面的内容 我的index.php页面有包含页面标题的模板,但我想在每个页面中设置每个页面标题 在index.php页面中,我将页面文件包含在标记中我有一个替代方法可能有用 不要关闭索引文件中的头标记,然后在内容文件中使用标记设置标题并关闭头标记 差不多 index.php <html> <head> <!--links---> <?php require "content.php";?> </html
在index.php页面中,我将页面文件包含在
标记中我有一个替代方法可能有用
不要关闭索引文件中的头标记,然后在内容文件中使用标记设置标题并关闭头标记
差不多
index.php
<html>
<head>
<!--links--->
<?php require "content.php";?>
</html>
<html>
<head>
<title><?php title_func(); ?></title>
</head>
<body>
require "content.php";
</body>
</html>
content.php文件:
<title>YOUR TITLE</title>
</head>
<body>
<!--your data-->
</body>
你的头衔
我有一种可能有用的替代方法
不要关闭索引文件中的头标记,然后在内容文件中使用标记设置标题并关闭头标记
差不多
index.php
<html>
<head>
<!--links--->
<?php require "content.php";?>
</html>
<html>
<head>
<title><?php title_func(); ?></title>
</head>
<body>
require "content.php";
</body>
</html>
content.php文件:
<title>YOUR TITLE</title>
</head>
<body>
<!--your data-->
</body>
你的头衔
您可以使用javascript或jquery来实现这一点。
首先,给标题一个id
<title id='page_title'>My Page</title>
编辑
@Purushotam所说的也可以起作用您可以使用javascript或jquery来实现这一点。 首先,给标题一个id
<title id='page_title'>My Page</title>
编辑
@Purushotam所说的同样适用于另一种解决方案
你可以这样做
index.php
<html>
<head>
<!--links--->
<?php require "content.php";?>
</html>
<html>
<head>
<title><?php title_func(); ?></title>
</head>
<body>
require "content.php";
</body>
</html>
需要“content.php”;
content.php
只要把这个函数放在任何地方就行了
<?php
function title_func(){
echo "title here";
}
?>
另一种解决方案
你可以这样做
index.php
<html>
<head>
<!--links--->
<?php require "content.php";?>
</html>
<html>
<head>
<title><?php title_func(); ?></title>
</head>
<body>
require "content.php";
</body>
</html>
需要“content.php”;
content.php
只要把这个函数放在任何地方就行了
<?php
function title_func(){
echo "title here";
}
?>
如果SEO对你很重要,那么你会想避开这一点我认为这是非常真实的如果SEO对你很重要,那么你会想避开这一点我认为这是非常真实的