Home>Article>PHP Framework> How to call functions in thinkphp
thinkphp template calls the function method:
{变量|函数1|函数2|函数3=参数1,参数2,参数3,###}is the 4th parameter, which represents the replacement of the variable with the 4th parameter Example:
{$username|substr=0,3}取标题中前3个字符 {$times|date='Y-m-d H:i:s',###}将times时间戳转换为日期格式Usage of colon execution function: output method and execute return value
{:U('user/insert')}Example:
{:time()} 会输出当前日期格式 ,会被解析成Usage of wavy line function: execution method but Do not output
{~function()}Example:
{~substr("aaaaaaa",3)} 执行后不会输出,会背解析成
{$Think.get.url中get过来的参数} {$Think.server.server中的变量} {$Think.session.session中的id|md5} 如果需要的话还可以对值MD5一下 {$Think.cookie.cookie中的id}
{$Think.config.db_host} 读取config中的配置信息 {($title)?($title):'当前没有值'} 当前参数若没有值,则显示后面的描述
aaaaaa bbbbbbbbb 没有数据
a等于3 a不等于3 a的长度等于1 a长度不等于1
or use ###变量a值在1,2,3,4范围内就打印 变量a值不在1,2,3,4范围内就打印
a在1,2,3,4范围内 //type改为notin就是不在,该方法可替代in和notin
a变量为空 a变量不为空
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!