Smarty Retention variable usage Analysis _php instance

Source: Internet
Author: User
Tags php template smarty template

The examples in this article describe the use of smarty retention variables. Share to everyone for your reference, specific as follows:

{$smarty} variable does not need to be allocated, it can be directly in the template, used 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 from the following ways:

{$smarty. Get}

Get URL parameters with $_get

For example: $_get[' page ' gets through {$smarty. Get.page}

{$smarty. Post}

Get Parameters with $_post

{$smarty. Request}

Get request parameters with $_request

{$smarty. Cookie}

Get Cookies 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} respectively, some First,last,index property values are available

{$smarty. Template}

Returns the name of the current template

{$smarty. Version}

Smarty version

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

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

More interested in smarty related content readers can view the site topics: "Smarty Template Primer Tutorial", "PHP Template Technology Summary", "PHP based on PDO Operation Database Skills summary", "PHP Operations and Operator Usage Summary", "PHP Network Programming Skills Summary", " Introduction to PHP Basic Grammar, "Introduction to PHP object-oriented programming", "PHP string (String) Usage Summary", "Php+mysql Database Operations Tutorial" and "PHP common database Operation Skills Summary"

I hope this article will help you with the PHP program design based on Smarty template.

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.