我希望动态写入关键字和描述元标记。我看到了这个thead,但我不能对元标记做同样的事情。
这是我的代码:http://runnable.com/VCSYsvEy0xov2fNi/my-for-php
的index.php
<?php
ob_start (); // Buffer output
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title><!--TITLE--></title>
<meta http-equiv="Content-Language" content="it" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="keywords" content="<!--KEYWORDS-->" />
<link rel="stylesheet" type="text/css" href="template/style.css">
<script type="text/javascript" src="config/expand.js"></script>
<script type="text/javascript" src="config/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="config/scriptbreaker-multiple-accordion-1.js"></script>
<script language="JavaScript">
$(document).ready(function() {
$(".topnav").accordion({
accordion:false,
speed: 500,
closedSign: '[+]',
openedSign: '[-]'
});
});
</script>
</head>
<body>
<div id="container">
<div id="banner"><?php include('template/banner.php') ?></div>
<!--<div id="nav_main"><?php include('template/nav_main.php') ?></div> -->
<div id="navigation_left"><?php include("template/link_left.php") ?></div>
<div id="navigation_right" align="left"><?php include("template/link_right.php") ?></div>
<div id="content"><?php include("$page.php") ?> </div>
<div id="footer"><?php include('template/footer.php') ?></div>
</div>
</body>
</html>
<?php
$pageContents = ob_get_contents (); // Get all the page's HTML into a string
$pageKeywords = ob_get_contents();
ob_end_clean (); // Wipe the buffer
// Replace <!--TITLE--> with $pageTitle variable contents, and print the HTML
echo str_replace ('<!--TITLE-->', $pageTitle, $pageContents);
echo str_replace ('<!--KEYWORDS-->', $pageKey, $pageKeywords);
?>
home.php(主页)
<?php $pageTitle = 'Full Metal Panic Italy | Home';?>
<?php $pageKey = 'full, metal, panic, fmp, fumoffu, the second raid, spoiler, mithril, amalgam, sigma';?>
<p style="background:#aaf">
Lorem ipsum dolor sit amet, consectetaur adipisicing elit, sed do eiusmod tempor
incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud
exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute
irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla
pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui
officia deserunt mollit anim id est laborum.
</p>
标题可行,但不适用于元 我究竟做错了什么?
答案 0 :(得分:0)
这样做
$pageContents = ob_get_contents (); // Get all the page's HTML into a string
ob_end_clean (); // Wipe the buffer
// Replace <!--TITLE--> with $pageTitle variable contents, and print the HTML
$pageContents = str_replace ('<!--TITLE-->', $pageTitle, $pageContents);
$pageContents = str_replace ('<!--DESCRIPTION-->', $pageDesc, $pageContents);
echo str_replace ('<!--KEYWORDS-->', $pageKey, $pageContents);