Some applications of Smarty in the template file _ PHP Tutorial

Source: Internet
Author: User
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.

 
 
  1. {$foo+1}
  2. {$foo*$bar}
  3. {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

 
 
  1. {* Display the GET value from the URL "page "*}
  2. {$ Smarty. get. page}
  3. {* Display the variable "page" * from a form (POST "*}
  4. {$ Smarty. post. page}
  5. {* Display the cookie "username" value *}
  6. {$ Smarty. cookies. username}
  7. {* Display server variable "SERVER_NAME "*}
  8. {$ Smarty. server. SERVER_NAME}
  9. {* Display the system environment (env) variable "PATH "*}
  10. {$ Smarty. env. PATH}
  11. {* Display the PHP session variable "id "*}
  12. {$ Smarty. session. id}
  13. {* Display the variable "username" from get/post/cookies/server/env "*}
  14. {$ 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.

 
 
  1. {$ Smarty. now | date_format: "% Y-% m-% d % H: % M: % S "}
  2. {* Here the Smarty variable modifier is used *}

4. you can use {$ smarty. const} to directly access PHP constants.

 
 
  1. {$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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.