Example of post usage in smarty

Source: Internet
Author: User
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.

,

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.