Home  >  Article  >  Backend Development  >  Problem defining data variables in smarty

Problem defining data variables in smarty

WBOY
WBOYOriginal
2016-08-08 09:18:581266browse

How to define an array in smarty? After referring to smarty's official website documentation, I found that the following method can be used:

定义数组: {assign var=foo value=[1,2,3]} {assign var=foo value=['y'=>'yellow','b'=>'blue']} {assign var=foo value=[1,[9,8],3]} // 可嵌套

Then var_dump, {$foo|var_dump}, and the array can be printed successfully.

However, please note that this syntax does not exist in smarty2. The variable assigned by the above assignment will become a string. Special attention should be paid to this point

Copyright statement: This article is an original article by the blogger, No reproduction is allowed without the permission of the blogger.

The above introduces the problem of defining data variables in smarty, including the relevant aspects. I hope it will be helpful to friends who are interested in PHP tutorials.

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
Previous article:Nginx2: working mechanismNext article:Nginx2: working mechanism