Smarty template retention variable summary_php tutorial

Source: Internet
Author: User
Smarty template retention variable summary. I haven't used Smarty for a project for a long time. today, I suddenly want to modify some of my website's content, because my website was made a long time ago using the smarty template engine, I have not used Smarty for projects in some places for a long time. today, I suddenly want to modify some of my website's content, because my website was made using the smarty template engine a long time ago, I felt I had to search for the answer on the internet in some places. it seems that the long-lost smarty has been getting unfamiliar, so I have to study it quickly. Summarize the reserved variables of the Smarty template for future use.

The reserved variable {$ smarty} is a special variable that can be directly accessed in the template and does not need to be allocated from the PHP script.

{$ Smarty. get}, {$ smarty. post}, and so on are used to access the page request Variables. the main page request variables include get, post, cookies, server, enviroment, and session variables. For example, {$ smarty. server. SERVER_NAME} gets the server variable, {$ smarty. env. PATH} obtains the path of the system environment variable {$ smarty. request. password} obtains the compound variable of get/post/cookies/server/env.

{$ Smarty. ldelim} and {$ smarty. rdelim} are used to display the left and right separators currently in use.

{$ Smarty. now} is used to access the current timestamp. you can use the date_format regulator to format the output. for example, {$ smarty. now | date_format: "% Y-% m-% d % H: % M: % S"}. output format: 07:19:09

{$ Smarty. const} directly accesses PHP constants. for example, {$ smarty. const. _ FILE __} is equivalent to the _ FILE _ constant in php. of course, you can also access custom constants.

{$ Smarty. capture} can output the data in the {capture} .. {/capture} tag through {$ smarty. capture. name. For detailed usage of capture, refer to http://www.phpernote.com/php-template-framework/43.html

The {$ smarty. config} {$ smarty} variable can access the loaded config variable. Note that the page template must first load a variable similar to {config_load file = "web. conf "}. For example, {$ smarty. config. pageTitle} indicates {# pageTitle #}.

{$ Smarty. section} and {$ smarty. foreach} can access the attributes of the 'secure' and 'foreach' loops.

{$ Smarty. template} displays the name of the currently processed template.

{$ Smarty. version} displays the version number of the currently used smarty template engine.

Articles you may be interested in
  • Use php functions in the smarty template and how to use multiple functions for a variable in the smarty Template
  • Add the latest tag to the information in the smarty Template
  • Smarty template variable Operator summary
  • How to generate a random number in the smarty Template
  • Extension of the for loop in the smarty Template
  • How to use variables in smarty include file
  • How to use constants defined by define in a program in a smarty Template
  • Summary of common system variables in Thinkphp templates

...

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.