Mainly introduces the usage of php to generate shtml class. It describes in more detail the class file that generates shtml and the corresponding usage examples. It has certain reference value. Friends in need can refer to it, or you can make it according to your own needs. require various modifications.
The first step is to download the php generated shtml class library we need to use for this course: http://www.php.cn/xiazai/leiku/491
Second Step. After the download is completed, find the php class file we need, unzip it to our local directory, and create a new php file!
The third step, after completion, we need to call this class in the new php file and instantiate the class:
<?php include_once "shtml.php";//引入类文件 //定义文件内容 $arr = array(); $arr["title"] = "php中文网"; $arr["content"] = "www.php.cn"; $obj = new Shtml; //实例化 $obj->FileName="xxx.htm"; //生成文件的名字 $obj->Templet="网站名称:<FIELD_title> 网站地址:<FIELD_content>"; //生成文件内容 $obj->BindData($arr); //一切OK,万事达吉 $obj->Create(); ?>
Run the file, and the result will be as shown below:
Note:
1. Although we execute the file, what page None, but the file has been created locally
2. As shown in the figure below, we have created the file :
#
The above is the detailed content of Sharing development examples of how php generates shtml. For more information, please follow other related articles on the PHP Chinese website!