smarttemplate中能assign参数吗? smarttemplate里面assign变量值给变量,你看你那个参数能做变量么?因为RESULT:id=22不是合格的变量名称,我觉得应该是不可以的。要不然你看看解析后的生成的tmp目录里面的文件。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1、不可以,因为smarttemplate的模板变量只允许是字母数字下划线。所以RESULT:id=22不会被替换2、你的 {RESULT:id=22} 倒很想一个模板函数,如果你是这样的话应该写做{RESULT:"22"}另外定义函数smarttemplate_extensions/smarttemplate_extension_result.php<?phpfunction smarttemplate_extension_result($id) {....}?>而无须其他操作如果参数id是变量则写做{RESULT:id}用assign("id",22)赋值即可 最近我也在看smarttemplatesmarttemplate_extensions/smarttemplate_extension_text.phpfunction smarttemplate_extension_text ( $name, $key,$value ){ return "<input name=\"".$name."[".$key."]\" type=\"text\" value=\"".$value."\" size=\"12\" maxlength=\"50\">";}不知怎么输出结果不对 谢谢唠叨等大大...我试了唠叨的第二种方法。不是太合意。因为{RESULT:"22"}得到了一个最终结果,而我要考虑得出的结果能够用assign再处理。我尝试建立一个新的模板文件result.html用来assign{RESULT:"22"}中得到的结果,在smarttemplate_extension_result($id)函数中new SmartTemplate("result.html");如下: function smarttemplate_extension_result ( $id ) { $array = array(); $array['a'] = getDetail($id); $result= new SmartTemplate("result".EXT); $result->assign($array); echo $result->result(); //echo $indexcategory->result(); }不能得到执行。 下载文件的问题 appserv+DW远程调试问题(注:不是如何发布到互联网)? 急求解!!! 网易的邮箱登陆接口 php 中js第一次取不到值 招聘PHP程序员 请教高手:关于更改php服务器80端口的疑难问题? 如何学习pear和smarty? 匹配网页中的所有链接 如何另存为文本文件? 在linux 7.1 下面安装 php-4.0.6 的问题,请高手指点 郁闷,session就是不能使用!!! 在线编辑器里图片格式如
2、你的 {RESULT:id=22} 倒很想一个模板函数,如果你是这样的话应该写做
{RESULT:"22"}
另外定义函数smarttemplate_extensions/smarttemplate_extension_result.php
<?php
function smarttemplate_extension_result($id) {
....
}
?>
而无须其他操作如果参数id是变量则写做
{RESULT:id}
用assign("id",22)赋值即可
smarttemplate_extensions/smarttemplate_extension_text.php
function smarttemplate_extension_text ( $name, $key,$value )
{
return "<input name=\"".$name."[".$key."]\" type=\"text\" value=\"".$value."\" size=\"12\" maxlength=\"50\">";
}
不知怎么输出结果不对
function smarttemplate_extension_result ( $id )
{
$array = array();
$array['a'] = getDetail($id);
$result= new SmartTemplate("result".EXT);
$result->assign($array);
echo $result->result();
//echo $indexcategory->result();
}不能得到执行。