The examples in this article describe the usage of Smarty reserved variables. Share it with everyone for your reference, the details are as follows:
The {$smarty} variable does not need to be allocated. It can be used directly in the template to access some special template variables. There are many variables, such as: page request variables $_GET, $_POST, $_REQUEST, $_SESSION, $ _COOKIE, and some environment variables such as $_ENV and $_SERVER, which can be obtained directly through the following methods:
{$smarty.get}
Same as $_GET to get url parameters
For example: $_GET['page'] Get
through {$smarty.get.page}{$smarty.post}
Same as $_POST to get parameters
{$smarty.request}
Same as $_REQUEST to get request parameters
{$smarty.cookie}
Same as $_COOKIE to get cookies
{$smarty.session}
Same as $_SESSION to get session
{$smarty.server}
Same as $_SERVER to get server variables
{$smarty.env}
Same as $_ENV to get environment variables
{$smarty.now}
Same as time(), get timestamp
{$smarty.const}
Directly access PHP constants, such as {$smarty.const.__FILE__}
{$smarty.capture}
Template output captured via the built-in {capture}...{/capture} function can be accessed by {$smarty.capture.name}
{$smarty.section} {$smarty.foreach}
Used to access the loop attributes of {section} and {foreach} respectively. There are some first, last, index and other attribute values available
{$smarty.template}
Return the current template name
{$smarty.version}
smarty version
{$smarty.ldelim} {$smarty.rdelim}
is used to print the left delimiter and right delimiter, class {ldelim}{rdelim}
Readers who are interested in more Smarty-related content can check out the special topics on this site: "Basic Tutorial for Getting Started with Smarty Templates", "Summary of PHP Template Technology", "Summary of PHP Database Operation Skills Based on PDO", "PHP Operations and Operators" Usage summary", "PHP network programming skills summary", "PHP basic syntax introductory tutorial", "php object-oriented programming introductory tutorial", "php string (string) usage summary", "php mysql database operation introductory tutorial" and "Summary of Common Database Operation Skills in PHP"
I hope this article will be helpful to everyone’s PHP program design based on smarty templates.