Smarty reserved variable Usage Analysis, smarty variable usage

Source: Internet
Author: User

Smarty reserved variable Usage Analysis, smarty variable usage

This example describes how to use the Smarty reserved variable. We will share this with you for your reference. The details are as follows:

The {$ smarty} variable does not need to be assigned. It can be directly used 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 other environment variables, such as $ _ ENV and $ _ SERVER, can be obtained directly using the following methods:

{$smarty.get}

GET url parameters with $ _ GET

For example, $ _ GET ['page'] is obtained through {$ smarty. get. page }.

{$smarty.post}

Same as $ _ POST for obtaining Parameters

{$smarty.request}

Same as $ _ REQUEST for REQUEST Parameters

{$smarty.cookie}

Get COOKIE with $ _ cookie

{$smarty.session}

Get the SESSION with $ _ session

{$smarty.server}

Get SERVER variables with $ _ SERVER

{$smarty.env}

Get environment variables with $ _ ENV

{$smarty.now}

Same as time (), get Timestamp

{$smarty.const}

Directly access PHP constants, such as {$ smarty. const. _ FILE __}

{$smarty.capture}

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

{$smarty.section} {$smarty.foreach}

Used to access the cyclic attributes of {section} and {foreach} respectively. Some attribute values such as first, last, and index are available.

{$smarty.template}

Returns the name of the current template.

{$smarty.version}

Smarty version

{$smarty.ldelim} {$smarty.rdelim}

Used to print the left separator and right separator, class {ldelim} {rdelim}

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.