Home  >  Article  >  Backend Development  >  Post usage examples in smarty, smartypost examples_PHP tutorial

Post usage examples in smarty, smartypost examples_PHP tutorial

WBOY
WBOYOriginal
2016-07-13 10:12:49740browse

Examples of post usage in smarty, examples of smartypost

The example in this article describes the usage of post in smarty. Share it with everyone for your reference. The specific analysis is as follows:

After knowing how smarty works, I want to write a post implementation process. The following is the code to implement post. It is similar to writing PHP code alone, except that there are more display files

Configuration file: conf.php

Copy code The code is as follows:
@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
Copy code The code is as follows:
include 'conf.php';
$my->assign('content','welcome to arrival');
$my->assign('mylife',array("life","eating","dream","cool breeze","revenge","fuck someone","fuck you die"));
$my->display('kk.html');
?>

kk.html under template [display file of index.php]
Copy code 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
Copy code The code is as follows:
include 'conf.php';
$kk=$_POST['conteng'];
$ct=$_POST['ct'];
$sm=new Smarty();
$sm->assign('content',$kk);
$k=explode("rn",$ct); //Separate characters into arrays
$sm->assign('ml',$k);
$sm->display('m.tpl');
?>

m.tpl file under template [display file of submit.php]
Copy code The code is as follows:
{$content}
{section name=kk loop=$ml}
{$ml[kk]}

{/section}

I hope this article will be helpful to everyone’s smarty programming design.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/919261.htmlTechArticleExamples of post usage in smarty, smartypost examples This article describes the usage of post in smarty. Share it with everyone for your reference. The specific analysis is as follows: After knowing the operating principle of smarty,...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn