Home  >  Article  >  Backend Development  >  How to use php shtml to generate class belt_PHP tutorial

How to use php shtml to generate class belt_PHP tutorial

WBOY
WBOYOriginal
2016-07-20 11:07:15784browse

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 in the template string
$tmp = str_replace('',$value,$tmp);
}
//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: Content: ";
$obj->BindData($arr);
//Everything is OK, MasterCard Ji
$obj->Create();*/
?>


http://www.bkjia.com/PHPjc/444973.html

truehttp: //www.bkjia.com/PHPjc/444973.htmlTechArticlephp tutorial shtml generation class band usage?php class Shtml{ var $DataSource; //array var $Templet; //string var $FileName; //Bind data source function BindData($arr){ $this-DataSource...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn