Smarty analysis of the use of reserved variables

Source: Internet
Author: User
Tags smarty template
This paper mainly introduces the usage of smarty reserved variables, introduces the function and use method of Smarty common reserved variables in detail, and needs friends to refer to them. We hope to help you.

Specific as follows:

{$smarty} variables do not need to be assigned, it can be directly in the template, to access some special template variables, there are many variables, such as: page request variable $_get,$_post,$_request,$_session,$_cookie, there are some such as environment variable $ _env,$_server, they can be obtained directly in the following ways:

{$smarty. Get}

Get URL parameters with $_get

such as: $_get[' page '] through {$smarty. Get.page} Get

{$smarty. Post}

Get Parameters with $_post

{$smarty. Request}

Get request parameters with $_request

{$smarty. Cookies}

Get a cookie with $_cookie

{$smarty. Session}

Get session with $_session

{$smarty. Server}

Get Server variables with $_server

{$smarty. env}

Get environment variables with $_env

{$smarty. Now}

Same time (), get timestamp

{$smarty. Const}

Direct access to PHP constants, such as {$smarty. const.__file__}

{$smarty. Capture}

Through the built-in {capture} ... The template output captured by the {/capture} function can be accessed by {$smarty. Capture.name}

{$smarty. Section} {$smarty. foreach}

Used to access the loop properties of {section} and {foreach}, and some First,last,index property values are available

{$smarty. Template}

Returns the current template name

{$smarty. Version}

Smarty version

{$smarty. Ldelim} {$smarty. Rdelim}

Used to print left and right delimiters, class {Ldelim}{rdelim}

Related recommendations:

CI Framework Integration Smarty Example detailed

An explanation of how the Smarty template engine caches

Smarty template engine Video teaching materials course recommendation

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.