


ThinkPHP template judgment output Defined tag usage detailed explanation_PHP tutorial
Jul 13, 2016 am 10:26 AM
The defined tag of the ThinkPHP template engine is used to determine whether the constant has been defined .
ThinkPHP's defined tag is used to determine whether a constant has been defined. Its function is equivalent to the defined() function in PHP. The defined tag is used as follows:
<present name="常量">要输出的内容</present>
First define a constant in the module operation (such as: Index/display) and output the template:
define("SITE_NAME", "脚本之家"); $this->display();
Use the defined tag in template/Tpl/default/Index/display.html as follows:
<defined name="SITE_NAME">网站名称:{*SITE_NAME}</defined>
Running this example will output:
网站名称:脚本之家
The equivalent PHP code for this example is as follows:
<?php if(defined("SITE_NAME")){ echo '网站名称:',constant("SITE_NAME"); } ?>
If the judgment is not defined, you can use:
<notdefined name="SITE_NAME">{*SITE_NAME}不存在活未定义</notdefined>
The above two examples are combined as follows:
<defined name="SITE_NAME">网站名称:{*SITE_NAME}<else/>{*SITE_NAME}不存在活未定义</defined>

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

There are several versions of thinkphp

How to search for text across all tabs in Chrome and Edge

Which one is better, laravel or thinkphp?

How to add tags on Douyin to attract traffic? Which tags on the platform are easiest to attract traffic to?
