PHP简单演示如何使用模板制作静态页面
http://www.itjxue.com 2015-07-17 08:20 来源:未知 点击次数:
简单演示PHP如何使用模板生成静态页面。
模板文件templets.htm:
<html>
<head>
<title>{title}</title>
</head>
<body>
<p>Hello {hello}</p>
</body>
</html>
PHP文件代码:
<?php
$title = 'itjxue';
$hello = 'itjxuecom!';
$file = file_get_contents('templets.htm');
$file = str_replace(array('{title}','{hello}'),array($title,$hello), $file);
echo $file;
?>
(责任编辑:IT教学网)
上一篇:PHP程序员都应该会用的五个工具
下一篇:PHP入门指导:如何学习PHP?