1.介绍
a. interface
b. implements
c. extends
2.使用
<?
interface ITemplate
{
public function setVariable($name,$var);
public function getHTML($template);
}
class Template implements ITemplate{
private $vars=array();
public function setVariable($name,$var){
$this->$vars[$name]=$var;
}
public function getHTML($template){
foreach($this->vars as $name=>$value){
$temolate=str_replace("{{$name}}",$value,$template)
}
return $template;
}
}
$template_str=<<<HTML
<html>
<title>{title}</title>
HTML;
$t=new Template();
$t->setVariable('title','this a title');
$html=$t->getHTML($template_str);
echo $html;