• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

smarty中post用法实例_PHP

php 搞代码 3年前 (2022-01-25) 23次浏览 已收录 0个评论

本文实例讲述了smarty中post用法。分享给大家供大家参考。具体分析如下:

知道了smarty的运行原理之后,就想写个post的实现过程,以下是实现post的代码,跟独自写php代码差不多,只是多了显示文件

配置文件:conf.php

<?php  <br />@header("Content-type: text/html; charset=UTF-8");  <br />require '../libs/Smarty.class.php';  <br />$my=new Smarty;  <br />$my->template_dir ='templates/';  <br />$my->compile_dir ='templates_c/';  <br />$my->config_dir ='co<div>)本文来源gaodai.ma#com搞#代!码网_</div><strong>搞代gaodaima码</strong>nfigs/';  <br />$my->cache_dir ='cache/';  <br />?>

index.php

<?php  <br />include 'conf.php';  <br />$my->assign('content','welcome to arrival');  <br />$my->assign('mylife',array("生活","吃饭","梦想","凉风","报仇","fuck someone","fuck you die"));  <br />$my->display('kk.html');  <br />?>

template下的kk.html【index.php的显示文件】

  <br />  <br />  <br /><meta http-equiv="Content-Type" content="text/html; charset=utf-8" />  <br /><title>无标题文档</title>  <br />  <br /><body>  <br />{$content}  <br />{section name=truelife loop=$mylife}  <br />{$mylife[truelife]}  <br />{/section}  <br />  <p>{html_select_time use_24_hours=true} 


submit.php

<?php  <br /> include 'conf.php';  <br /> $kk=$_POST['conteng'];  <br /> $ct=$_POST['ct'];  <br /> $sm=new Smarty();  <br /> $sm->assign('content',$kk);   <br /> $k=explode("\r\n",$ct);  //将字符分隔为数组  <br /> $sm->assign('ml',$k);  <br /> $sm->display('m.tpl');  <br />?>

template下的m.tpl文件【submit.php的显示文件】

{$content}  <br />{section name=kk loop=$ml}  <br />{$ml[kk]}<br />  <br />{/section}

希望本文所述对大家的smarty程序设计有所帮助。


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:smarty中post用法实例_PHP

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址