How to configure Smarty framework in PHP to implement PHP code and HTML code separation

Source: Internet
Author: User

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%&gt, 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.