Usage of the output Defined tag determined by the ThinkPHP template _ php instance

Source: Internet
Author: User
This article describes how to use the ThinkPHP template to determine the output Defined tag. For more information, see the defined tag of the ThinkPHP template engine. Determine whether a constant has been defined.
The defined tag of ThinkPHP is used to determine whether a constant has been defined. Its function Equivalent to the defined () function in PHP. The usage of the defined label is as follows:

 
  
Content to be output
 

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:

 
  
Website name: {* SITE_NAME}
 

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:

 
  
{* SITE_NAME} does not exist and is undefined.
 

The preceding two examples are merged as follows:

 
  
Website name: {* SITE_NAME}
  {* SITE_NAME} does not exist and is undefined.
 

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.