In Smarty, there are reserved variables that are not required to be allocated by the PHP script and can be used directly, i.e. without using $_tpl->assign (' var ', ' value ') to allocate.
1. Accessing the page request variables in the template
{$smarty. get.user} = = $_get[' user ')
{$smarty. post.user} = = $_post[' user ')
{$smarty. cookie.username} = = $_cookie[' username ')
{$smarty. session.username} = = $_session[' username ')
{$smarty. server.remote_addr} = = $_server["REMOTE_ADDR"]
{$smarty. Env.path} = = $_env[' PATH ')
{$smarty. request.username} = = $_request[' username ')
2. Accessing the constants and system constants defined in the PHP script in the template file
{$smarty. const.__file__} currently executing PHP file
{$smarty. Const.const_var} accesses define-defined constants in PHP scripts
3. Get the current server time in the template file
{$smarty. Now|date_format: "%y-%m-%d%h:%m:%s"} = = date in php script (' y-m-d h:i:s ', Time ())
4. configuration file access in the template
You can access the template variables in the configuration file by {$smarty. config. Configuration variable}. In this case, there are two ways to access the variables in the configuration file in the template: one, {#配置变量 #}, two, {$smarty. config, config variable}, if there is a region.
5. Get data captured by Smarty built-in function capture
The function of the capture function is to capture data from the template output and store it in a variable instead of outputting it to the page, and any data between {capture Name= "foo"} and {/capture} will be stored in the variable $foo, which is specified by the Name property. The variable is accessed through $smarty.capture.foo in the template, and if the Name property is not specified, the function defaults to use "default" as the argument
Excerpt from: Lee's Column
http://www.bkjia.com/PHPjc/478571.html www.bkjia.com true http://www.bkjia.com/PHPjc/478571.html techarticle in Smarty, there are reserved variables that are not required to be allocated by PHP scripts and can be used directly, i.e. without using $_tpl-assign (Var,value) to allocate. 1, in the template to access the page please ...