How to use php tutorial shtml to generate class belts
class Shtml{
var $DataSource; ;
//Bind data source
function BindData($arr){
$this->DataSource = $arr;
}
function Create() {
//Just talk about ideas, write it yourself:
$tmp = $this->Templet;
foreach($this->DataSource as $key=>$value){
//Replace the string of
$tmp = str_replace('
}
//Generate file and save.
$fp = fopen($this->FileName,'w');
if (fwrite ($fp,$tmp)){
fclose ($fp);
}else {
fclose ($fp);
}
}
}
//Usage:
/*$arr = array();
$arr[" title"] = "Here is the title";
$arr["content"] = "Here is the content";
$obj = new Shtml;
$obj->FileName="xxx.htm ";
$obj->Templet="Title:
$obj->BindData($arr);
//Everything is OK, MasterCard Ji
$obj->Create();*/
?>
http://www.bkjia.com/PHPjc/444973.html