This article describes how to use the ThinkPHP template to determine the output Defined tag. For more information, see
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 is used to determine whether a constant has been defined.
The defined tag of ThinkPHP is used to determine whether a constant has been defined. Its function is 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.
,