Two simple templates:
Copy Code code as follows:
<title>{title}</title>
<body>
<font color=red size=6><center>{title}</center></font>
<pre>{body}</pre>
</body>
Copy Code code as follows:
<title>{title}</title>
<body>
<font Color=green size=7><center>{title}</center></font>
<pre>{body}</pre>
</body>
Http_template_it class library must be installed first
Copy Code code as follows:
<?php
Require_once "html/template/it.php";
Creates a new Html_template_it object, where the parameter is the path of the template file
$template = new Html_template_it (' templates/');
Read the template file and get template information by reading the parameters on the address bar
$template->loadtemplatefile ($_get[' template '). " HTM ");
Setting parameters in a stencil
$template->setvariable (' title ', ' Html_template_it ');
$template->setvariable (' body ', ' Hello World ');
Show Page
$template->show ();
?>
You can find the template replacement effect by writing to the browser as follows:
Http://localhost:8082/file:/F:/php/phpcode/23/23.4.3/23.4.3.php?template=T2
Http://localhost:8082/file:/F:/php/phpcode/23/23.4.3/23.4.3.php?template=T1