Usage of the output Defined tag determined by the ThinkPHP Template

Source: Internet
Author: User

The defined tag of the ThinkPHP template engine is usedDetermine whether a constant has been defined.
The defined tag of ThinkPHP is used to determine whether a constant has been defined. Its functionEquivalent to the defined () function in PHP. The usage of the defined label is as follows:

<Present name = "constant"> content to be output </present>

Define a constant in a module operation (such as Index/display) and output the template:

Define ("SITE_NAME", ""); $ this-> display ();

Use the defined tag in the template/Tpl/default/Index/display.html as follows:

<Defined name = "SITE_NAME"> website name: {* SITE_NAME} </defined>

Running this example will output:

Website name: script home

The equivalent php code in this example is as follows:

<? Phpif (defined ("SITE_NAME") {echo 'website name: ', constant ("SITE_NAME") ;}?>

If the judgment is not defined, you can use:

<Notdefined name = "SITE_NAME"> {* SITE_NAME} does not exist. The live definition is not defined. </notdefined>

The preceding two examples are merged as follows:

<Defined name = "SITE_NAME"> website name: {* SITE_NAME} <else/> {* SITE_NAME} No active undefined </defined>

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.