Smarty simple entry instance, smarty instance. Smarty simple Getting started instance. smarty instance this article uses a simple instance to analyze the usage of smarty. Share it with you for your reference. The specific analysis is as follows: smarty creates a configuration file and displays the smarty simple entry instance and smarty instance
This article uses a simple example to analyze the usage of smarty. Share it with you for your reference. The specific analysis is as follows:
After smarty creates a configuration file and a display file, the configuration file display file is separated, so that the artist and the development work can be perfectly separated.
Configuration page code: index. php
The code is as follows:
<? Php
@ Header ("Content-type: text/html; charset = UTF-8 ");
Require '../libs/Smarty. class. php ';
$ My = new Smarty;
$ My-> template_dir = 'Templates /';
$ My-> compile_dir = 'Templates _ c /';
$ My-> config_dir = 'configs /';
$ My-> cache_dir = 'cache /';
$ My-> assign ('content', 'Welcome to arrival ');
$ My-> assign ('mylife', array ("Life", "eat", "dream", "Liangfeng "));
$ My-> display('kk.html '); // Display kk.html in the smartydirectory
?>
Kk.html
The code is as follows:
Untitled Document
{$ Content}
{Section name = truelife loop = $ mylife}
{$ Mylife [truelife]}
{/Section}
I hope this article will help you design your smarty program.
This article uses a simple example to analyze the usage of smarty. Share it with you for your reference. The specific analysis is as follows: smarty creates a configuration file and displays it...