使用PHP搜索Html标记

使用PHP搜索Html标记,php,html,codeigniter-2,Php,Html,Codeigniter 2,在我的rootfolder/xxx/header.php页面中,有一些文本 我想用php代码像这样搜索html标签 这意味着我希望使用php代码更改标题标记内的文本 我该怎么做 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org

在我的rootfolder/xxx/header.php页面中,有一些文本

我想用php代码像这样搜索html标签

这意味着我希望使用php代码更改标题标记内的文本

我该怎么做

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title;?></title>
</head>
这是rootfolder/xxx/header.php文件代码:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>test</title>
</head>
这是views/themes/header.php代码:

<?php
    $this->theme_lib->get_header("xxx");
?>
我想将
测试更改为
即将启动
。 我该怎么做?


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo $title;?></title>
</head>

您可以将标题存储在SQL数据库中,并使用PHP动态调用它们,使用PHP更新数据库条目

<?php
 $con = mysql_connect("localhost","root","password");
 if (!$con)
   {
   die('Could not connect: ' . mysql_error());
   }

mysql_select_db("mysite1", $con);

$result = mysql_query("SELECT * FROM headers");

while($row = mysql_fetch_array($result))
   {
$title = $row['title']
   }

mysql_close($con);
 ?>

然后在页面下方的HTML部分

<title><? echo $title; ?></title>

您应该查看文档,它可能会证明很有用。您需要做的就是这样:

<title>{title}</title>
{title}

更好的方法是使用CodeIgniter模板框架。更多信息请参见。是的,我知道他在使用CodeIgniter。您不需要使用
而是使用此
{title}
<title>{title}</title>