For a long time did not use Smarty to do projects, and today suddenly to change their own website inside some things, because my site is a long time ago with smarty template engine do, change some places on the feeling still have to search the answer on the Internet, it seems to the long-lost Smarty has started unfamiliar, hurriedly tutorial. Make a summary of the reserved variables of the Smarty template for later use.
{$smarty} The reserved variable is a special variable that can be accessed directly in the template and does not need to be allocated from a PHP script.
{$smarty. get},{$smarty. Post} and so on to access page request variables, the main page request variables are get,post,cookies,server,enviroment and session variables. For example {$smarty. server.server_name} Gets the server variable, {$smarty. Env.path} Gets the system environment variable PATH, {$smarty. Request.password} gets get/post/ The compound variable of the cookies/server/env.
{$smarty. Ldelim} and {$smarty. Rdelim} are used to display the currently used left and right separators
{$smarty. Now} is used to access the current timestamp. The output can be formatted with the Date_format regulator. For example {$smarty. Now|date_format: "%y-%m-%d%h:%m:%s"}, Output format: 2012-08-01 07:19:09
{$smarty. Const} accesses PHP constants directly. For example {$smarty. const.__file__} is equivalent to the __FILE__ constant in PHP, and of course you can access custom constants.
{$smarty. Capture} can be {capture}. The data in the {/capture} tag is output through {$smarty. Capture.name}. For more detailed usage of capture, refer to http://www.phpernote.com/php-template-framework/43.html
{$smarty. config} {$smarty} variable can access the config variable that has already been loaded, note that the page template must first load a similar {config_load file= "web.conf"}. For example {$smarty. Config.pagetitle} can represent {#pageTitle #}.
{$smarty. Section}, {$smarty. foreach} can access the properties of the ' section ' and ' foreach ' loops.
{$smarty. Template} Displays the name of the template currently being processed.
{$smarty. Version} displays the version number of the Smarty template engine currently in use
Articles you may be interested in
- Use PHP functions in Smarty Templates and how to use multiple functions for a variable in a smarty template
- Add latest tags to information in smarty templates
- Smarty Template Variable operator summary
- How to generate random numbers in a smarty template
- Smarty extension for loop in template
- Smarty include file methods for using variables
- How constants defined by define in the program are used in the Smarty template
- Summary of System variables commonly used in thinkphp templates
http://www.bkjia.com/PHPjc/764135.html www.bkjia.com true http://www.bkjia.com/PHPjc/764135.html techarticle For a long time did not use Smarty to do the project, today suddenly to change their own website inside some things, because my site is a long time ago with the Smarty template engine to do, change to some places ...