Home >Backend Development >PHP Tutorial > smarty 截取字符串,调用php中的步骤,foreach循环

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

WBOY
WBOYOriginal
2016-06-13 12:37:58948browse

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

1.smarty截取字符串

      html中的代码     

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

 

2.smarty调用php中的方法

        html中的代码     

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

         php中的代码         

                                                 function sub($con){

                                                          return "123";

                                                 }

                                            ?>

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

           html中的代码        aa和bb是第二和第三个参数

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

           php中的代码         

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

                                                          return "123";

                                                 }

                                            ?>

3.foreach循环

             $row是从php页面传递过来的数组 

               

        

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn