Header (' cache-control:private ');//Keep the user fill in the information session_start ();//Open cache define (' Mycms ', ' UTF-8 ');//define Website Encoding constants define (' ROOT ', str_replace (' \ \ ', '/', Realpath (dirname (__file__)). ' /.. /'));//define the root directory constant: /is to return to the parent directory define (' TPL ', ROOT. ') /tpl ');//define the path to the page template define (' CONFIG ', ROOT. ') /config ');//define Core Toolkit path define (' MYCLASS ', config. ' /class ');//define class file storage path define (' Tpl_c ', ROOT. /tpl_c '),//define the cache path of the Smarty compiled file define (' Config_inc ', CONFIG. ' /inc ');//define the path//configuration of the Inc folder under the core package smartyrequire_once config_inc. '/smarty/smarty.class.php ';//Call Smarty's core file $tpl=new smarty;//instantiate a Smarty model $tpl->template_dir=tpl;//define the path to the site template $tpl->compile_dir=tpl_c;//define the cache path for the Smarty compiled file $tpl- >config_dir=config_inc. '/smarty ';//define Smarty's core package path $tpl->left_delimiter= ' <% ';//define Smarty's left delimiter $tpl-> Right_delimiter= '%> ';//define the right delimiter of the Smarty $tpl->debugging=false;//turn on the error console $tpl->caching=true;//turn on cache $tpl-> cache_lifetime=true;//turn on Cache lifetime//smarty configuration complete//test Smarty is configured successfully//$TPL->assign (' cms ', ' This is my first CMS ');//$TPL Display (TPL. ' /test.html ');
When testing, you only need to be in the HTMLCodeWrite <% $cms%>, and then run the program to see if you can output "This is my first CMS", if you can output, the Smarty configuration is successful, then you can use Smarty to the PHPCodeWith HTMLCodeThe realization of the perfect separation.
How to configure Smarty framework in PHP to implement PHP code and HTML code separation