The thinkphp template engine's defined tag is used to determine whether a constant has been defined .
Thinkphp's defined tag is used to determine whether a constant has been defined, and its function is equivalent to the defined () function in PHP . The defined tag usage is as follows:
<present name= "Constants" > What to Output </present>
First define a constant in the module operation (e.g. Index/display) and output the template:
Define ("Site_Name", "cloud-dwelling community");
$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>
Run the example output:
Site name: cloud-dwelling community
The equivalent PHP code for this example is as follows:
<?php
if (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 live undefined </notdefined>
The above two examples are merged as follows:
<defined name= "site_name" > website name: {*site_name}<else/>{*site_name} does not exist live undefined </defined>