Some applications of Smarty in the template file. 1 Mathematical operations can be directly applied to the variable {$ foo + 1} {$ foo * $ bar} {if ($ foo + $ bar % $ baz * 134232 + 10 + $ B + 10 )}... {if} 2GET, POST, SERVER, SESSIOM, COOKIES, and other page 1 mathematical operations can be directly applied to the variables in the template tag.
- {$foo+1}
- {$foo*$bar}
- {if ($foo+$bar%$baz*134232+10+$b+10)}...{/if}
2 GET, POST, SERVER, SESSIOM, COOKIES, and other page request variables can be directly accessed in the template
- {* Display the GET value from the URL "page "*}
- {$ Smarty. get. page}
-
- {* Display the variable "page" * from a form (POST "*}
- {$ Smarty. post. page}
-
- {* Display the cookie "username" value *}
- {$ Smarty. cookies. username}
-
- {* Display server variable "SERVER_NAME "*}
- {$ Smarty. server. SERVER_NAME}
-
- {* Display the system environment (env) variable "PATH "*}
- {$ Smarty. env. PATH}
-
- {* Display the PHP session variable "id "*}
- {$ Smarty. session. id}
-
- {* Display the variable "username" from get/post/cookies/server/env "*}
- {$ Smarty. request. username}
3. you can use {$ smarty. now} to access the current timestamp. you can use the date_format variable regulator to process specific output.
- {$ Smarty. now | date_format: "% Y-% m-% d % H: % M: % S "}
- {* Here the Smarty variable modifier is used *}
4. you can use {$ smarty. const} to directly access PHP constants.
- {$smarty.const.My_Val}
Http://www.bkjia.com/PHPjc/364273.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/364273.htmlTechArticle1 mathematical operations can be applied directly to variables {$ foo + 1} {$ foo * $ bar} {if ($ foo + $ bar % $ baz * 134232 + 10 + $ B + 10 )}... {/if} 2 GET, POST, SERVER, SESSIOM, COOKIES and other pages...