您好,登錄后才能下訂單哦!
post方法怎么在smarty中使用?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
配置文件:conf.php
復(fù)制代碼 代碼如下:
<?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
復(fù)制代碼 代碼如下:
<?php
include 'conf.php';
$my->assign('content','welcome to arrival');
$my->assign('mylife',array("生活","吃飯","夢想","涼風(fēng)","報仇","fuck someone","fuck you die"));
$my->display('kk.html');
?>
template下的kk.html【index.php的顯示文件】
復(fù)制代碼 代碼如下:
<!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
復(fù)制代碼 代碼如下:
<?php
include 'conf.php';
$kk=$_POST['conteng'];
$ct=$_POST['ct'];
$sm=new Smarty();
$sm->assign('content',$kk);
$k=explode("\r\n",$ct); //將字符分隔為數(shù)組
$sm->assign('ml',$k);
$sm->display('m.tpl');
?>
template下的m.tpl文件【submit.php的顯示文件】
復(fù)制代碼 代碼如下:
{$content}
{section name=kk loop=$ml}
{$ml[kk]}<br />
{/section}
看完上述內(nèi)容,你們掌握post方法怎么在smarty中使用的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注億速云行業(yè)資訊頻道,感謝各位的閱讀!
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。