PHP头条
热点:

smarty截取字符串,调用php中的步骤,foreach循环


smarty 截取字符串,调用php中的方法,foreach循环

1.smarty截取字符串

      html中的代码    <{$content|truncate:30:"..."}> 

                                 将$content字符串截取30个字符,后面的内容用 "..." 来代替

 

2.smarty调用php中的方法

        html中的代码      <{$content|sub}>

                                           将$content字符窜当成变量传递给php中的方法sub (这里的php页面是display html页面的php页面)

         php中的代码         

                                                 function sub($con){

                                                          return "123";

                                                 }

                                            ?>

          如果要传递多个参数给php页面中的方法

           html中的代码      <{$content|sub:"aa":"bb"}>  aa和bb是第二和第三个参数

                                           将$content字符窜当成变量传递给php中的方法sub (这里的php页面是display html页面的php页面)

           php中的代码         

                                                 function sub($con,$aa,$bb){

                                                          return "123";

                                                 }

                                            ?>

3.foreach循环

          <{foreach item=arr from=$row}>   $row是从php页面传递过来的数组 

                <{$arr.name}>

         <{/foreach}>

www.phpzy.comtrue/phprm/11435.htmlTechArticlesmarty截取字符串,调用php中的步骤,foreach循环 smarty 截取字符串,调用php中的方法,foreach循环 1.smarty截取字符串 html中的代码 将$content字符串截取30个字符,后面的内容用 "..." 来代替...

相关文章

相关频道:

PHP之友评论

今天推荐