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>