After reading Smarty, I feel that it is very useful, but I don't know how to generate html documents. I checked it online today and found a method.
After reading Smarty, I feel that it is very useful, but I don't know how to generate html documents. I checked it online today and found a method.
Directly send the code below
The Code is as follows:
/*
File: config_smarty.php
Done: Configure Smarty
Author: www.5dkx.com
Date: 2009-12-21
*/
Include_once ("../libs/smarty. class. php ");
Class MySmarty extends Smarty {
Function _ construct ()
{
$ This-> Smarty ();
$ This-> config_dir = "../config ";
$ This-> cache_dir = "../cache ";
$ This-> template_dir = "../template ";
$ This-> compile_dir = "../template_c ";
$ This-> cache = false;
}
}
$ Smart = new MySmarty ();
$ Smart-> assign ("title", "title ");
$ Smart-> assign ("content", "content ");
$ Smart-> display ('Article. tpl ');
$ Output = $ smart-> fetch ('Article. tpl ');
$ Path = "../html/1.html ";
$ Fp = fopen ($ Path, "w ");
Fwrite ($ fp, $ output );
Fclose ($ fp );
?>