What this article brings to you is about the method (code) of using functions in the view in TP5.1. It has certain reference value. Friends in need can refer to it. , hope it helps you.
<?php namespace app\test\controller; use think\Controller; class Index extends Controller { public function index() { $this->assign('email','1047588430@qq.com'); $this->assign('time',time()); $this->assign('user','cjk'); return $this->fetch(); } }
Use {$variable name|function} in the view
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Document</title> </head> <body> <h2>{$email} : {$email|md5}</h2> <h2>{$email} : {$email|md5|strtoupper}</h2> <h2>{$email} : {$email|substr=0,10}</h2> </body> </html>
Related recommendations:
code implementation of tp5 framework ajax asynchronously adding data
php implementation to generate mixed verification code and image verification code and test (code)
The above is the detailed content of TP5.1 How to use functions in view (code). For more information, please follow other related articles on the PHP Chinese website!