国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發 > PHP > 正文

smarty中post用法實例

2024-05-04 23:28:13
字體:
來源:轉載
供稿:網友
這篇文章主要介紹了smarty中post用法,以實例形式詳細分析了在smarty中POST的具體實現過程,包括了配置文件的調用與模板文件的實現,需要的朋友可以參考下
 
 

本文實例講述了smarty中post用法。分享給大家供大家參考。具體分析如下:

知道了smarty的運行原理之后,就想寫個post的實現過程,以下是實現post的代碼,跟獨自寫php代碼差不多,只是多了顯示文件

配置文件:conf.php

復制代碼代碼如下:
<?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
復制代碼代碼如下:
<?php  
include 'conf.php';  
$my->assign('content','welcome to arrival');  
$my->assign('mylife',array("生活","吃飯","夢想","涼風","報仇","fuck someone","fuck you die"));  
$my->display('kk.html');  
?>

template下的kk.html【index.php的顯示文件】
復制代碼代碼如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
<html xmlns="http://www.w3.org/1999/xhtml">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  
<title>無標題文檔</title>  
</head>  
<body>  
{$content}  
{section name=truelife loop=$mylife}  
{$mylife[truelife]}  
{/section}  
  <p>{html_select_time use_24_hours=true} </p>  
  <form id="form1" name="form1" method="post" action="submit.php">  
  <p>  
    <label for="conteng"></label>  
    <input type="text" name="conteng" id="conteng" />  
  </p>  
  <p>  
    <label for="ct"></label>  
    <textarea name="ct" id="ct" cols="45" rows="5"></textarea>  
  </p>  
    <input type="submit" name="submit" id="submit" value="提交" />  
</form>  
  <p> </p>  
</body>  
</html>

submit.php
復制代碼代碼如下:
<?php  
 include 'conf.php';  
 $kk=$_POST['conteng'];  
 $ct=$_POST['ct'];  
 $sm=new Smarty();  
 $sm->assign('content',$kk);   
 $k=explode("/r/n",$ct);  //將字符分隔為數組  
 $sm->assign('ml',$k);  
 $sm->display('m.tpl');  
?>

template下的m.tpl文件【submit.php的顯示文件】
復制代碼代碼如下:
{$content}  
{section name=kk loop=$ml}  
{$ml[kk]}<br />  
{/section}

 

希望本文所述對大家的smarty程序設計有所幫助。


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 永昌县| 汕头市| 岳阳县| 蓝田县| 凉山| 汉中市| 渝北区| 思南县| 堆龙德庆县| 成安县| 惠安县| 安塞县| 道孚县| 通城县| 双城市| 台北县| 建宁县| 奉节县| 屏边| 临漳县| 乾安县| 呈贡县| 密云县| 贡山| 喀喇| 平山县| 梁平县| 庐江县| 荆州市| 安阳市| 辽源市| 图木舒克市| 大悟县| 乳源| 宣武区| 米易县| 福贡县| 南投市| 道真| 星子县| 闻喜县|