This article mainly introduces the post usage in smarty, and analyzes in detail the implementation process of POST in smarty in the form of instances, including the call of the configuration file and the implementation of the template file, for more information, see
This article mainly introduces the post usage in smarty, and analyzes in detail the implementation process of POST in smarty in the form of instances, including the call of the configuration file and the implementation of the template file, for more information, see
This example describes the post usage in smarty. Share it with you for your reference. The specific analysis is as follows:
After learning the operating principle of smarty, I want to write a post implementation process. The following is the post implementation code, which is similar to the php code written by myself. It only adds more display files.
Configuration File: conf. 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 /';
?>
Index. php
The Code is as follows:
<? Php
Include 'conf. php ';
$ My-> assign ('content', 'Welcome to arrival ');
$ My-> assign ('mylife', array ("life", "dinner", "dream", "liangfeng", "Revenge", "fuck someone ", "fuck you die "));
$ My-> display('kk.html ');
?>
Kk.html under template[ index. php display file]
The Code is as follows:
Untitled document
{$ Content}
{Section name = truelife loop = $ mylife}
{$ Mylife [truelife]}
{/Section}
{Html_select_time use_24_hours = true}
Submit. php
The Code is as follows:
<? Php
Include 'conf. php ';
$ Kk = $ _ POST ['conteng'];
$ Ct = $ _ POST ['ct '];
$ Sm = new Smarty ();
$ Sm-> assign ('content', $ kk );
$ K = explode ("\ r \ n", $ ct); // separate characters into Arrays
$ Sm-> assign ('ml', $ k );
$ Sm-> display ('M. tpl ');
?>
M. tpl file under template [display file of submit. php]
The Code is as follows:
{$ Content}
{Section name = kk loop = $ ml}
{$ Ml [kk]}
{/Section}
I hope this article will help you design your smarty program.
,