使用 PHP 搜索 Html 标签
在我的 rootfolder/xxx/header.php 页面中有
我想使用 php 代码搜索像这样的 html 标签。
这意味着我想使用 php 代码更改标题标签内的文本。
我该怎么做?
这是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>
在我的控制器代码中:
$data['title'] = "Launching Soon";
$this->load->view('themes/header',$data);
这是views/themes/header.php 代码:
<?php
$this->theme_lib->get_header("xxx");
?>
theme_lib 是我在控制器代码中加载的库:
public function get_header($name = ""){
include($name.'/header.php');
}
我想更改
为
In my rootfolder/xxx/header.php page have <title>some text</title>
.
I want to search as like this html tags using php code.
That means i want change the text inside the title tag by using php code.
How can i do this?
This is the rootfolder/xxx/header.php file code:
<!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>
In my controller code:
$data['title'] = "Launching Soon";
$this->load->view('themes/header',$data);
This is the views/themes/header.php code:
<?php
$this->theme_lib->get_header("xxx");
?>
The theme_lib is a library i loaded in the controller code:
public function get_header($name = ""){
include($name.'/header.php');
}
I want to change the <title>test</title>
as <title>Launching Soon</title>
.
How can i do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您应该查看模板解析器文档,它可能会很有用。您需要做的就是这样:
You should review the Template Parser documentation it may prove useful. All you need to do is something like this:
您可以将标题存储在 SQL 数据库中,并使用 PHP 动态调用它们,使用 PHP 更新数据库条目
然后在页面下方的 HTML 部分中,
You could have the titles stored in a SQL database and call them dynamically with PHP, update the database entry with PHP
Then in the HTML part which is further down the page,