ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
{assign}用于在模板运行期间赋值给变量. > Note > 在模板中进行赋值,从根本上讲还是将程序逻辑放到显示层来进行了,在PHP端进行此操作会更好。请自行考虑。 <table border="1"> <colgroup data-filtered="filtered"> <col align="center" data-filtered="filtered"> <col align="center" data-filtered="filtered"> <col align="center" data-filtered="filtered"> <col align="center" data-filtered="filtered"> <col data-filtered="filtered"> </colgroup> <thead><tr> <th align="center">参数名称</th> <th align="center">类型</th> <th align="center">必选参数</th> <th align="center">默认值</th> <th>说明</th> </tr></thead> <tbody> <tr> <td align="center">var</td> <td align="center">string</td> <td align="center">Yes</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>被赋值的变量名</td> </tr> <tr> <td align="center">value</td> <td align="center">string</td> <td align="center">Yes</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>赋的值</td> </tr> <tr> <td align="center">scope</td> <td align="center">string</td> <td align="center">No</td> <td align="center"><span class="emphasis"><em>n/a</em></span></td> <td>变量的作用范围: 'parent','root' 或 'global'</td> </tr> </tbody> </table> {assign}例子 ``` _{assign var="name" value="Bob"}_ _{assign "name" "Bob"}_ _The value of $name is {$name}_. ``` 输出: ``` The value of $name is Bob. ```