How to call functions in thinkphp
thinkphp template calls the function method:
{变量|函数1|函数2|函数3=参数1,参数2,参数3,###}
Copy after login
{$username|substr=0,3}取标题中前3个字符 {$times|date='Y-m-d H:i:s',###}将times时间戳转换为日期格式
Copy after login
{:U('user/insert')}
Copy after login
{:time()} 会输出当前日期格式 ,会被解析成 <?php echo time(); ?>
Copy after login
{~function()}
Copy after login
{~substr("aaaaaaa",3)} 执行后不会输出,会背解析成 <?php substr ?>
Copy after login
{$Think.get.url中get过来的参数} {$Think.server.server中的变量} {$Think.session.session中的id|md5} 如果需要的话还可以对值MD5一下 {$Think.cookie.cookie中的id}
Copy after login
{$Think.config.db_host} 读取config中的配置信息 {($title)?($title):'当前没有值'} 当前参数若没有值,则显示后面的描述
Copy after login
<switch name=""> <case value="1">aaaaaa</case> <case value="2">bbbbbbbbb</case> <default />没有数据 </switch>
Copy after login
<eq name="a" value="3">a等于3<else />a不等于3</eq> <eq name="a|strlen" value="1">a的长度等于1<else />a长度不等于1</eq>
Copy after login
<in name="a" value="1,2,3,4">变量a值在1,2,3,4范围内就打印</in> <notin name="a" value="1,2,3,4">变量a值不在1,2,3,4范围内就打印</notin>
Copy after login
<range name="a" value="1,2,3,4" type="in">a在1,2,3,4范围内</range> //type改为notin就是不在,该方法可替代in和notin
Copy after login
<empty name="a">a变量为空</empty> <notempty name="a">a变量不为空</notempty>
Copy after login
The above is the detailed content of How to call functions in thinkphp. For more information, please follow other related articles on the PHP Chinese website!
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article
Assassin's Creed Shadows: Seashell Riddle Solution
3 weeks ago
By DDD
What's New in Windows 11 KB5054979 & How to Fix Update Issues
2 weeks ago
By DDD
Where to find the Crane Control Keycard in Atomfall
3 weeks ago
By DDD
Assassin's Creed Shadows - How To Find The Blacksmith And Unlock Weapon And Armour Customisation
1 months ago
By DDD
Roblox: Dead Rails - How To Complete Every Challenge
3 weeks ago
By DDD

Hot Tools

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
CakePHP Tutorial
1386
52

