Welcome 微信登录

首页 / 网页编程 / PHP / PHP使用模板制作静态页面简单演示

PHP使用模板制作静态页面简单演示2009-12-25简单演示PHP如何使用模板生成静态页面。

模板文件templets.htm:

<html>
<head>
<title>{title}</title>
</head>
<body>
<p>Hello {hello}</p>
</body>
</html>

PHP文件代码:

<?php
$title = "bianceng.cn" ;
$hello = "www.bianceng.cn!" ;
$file = file_get_contents ( "templets.htm" );
$file = str_replace (array( "{title}" , "{hello}" ),array( $title , $hello ), $file );
echo $file ;
?>