THINKPHP5.1在view中使用函数

<?php
namespace app\test\controller;
use think\Controller;
class Index extends Controller
{
    public function index()
    {
        $this->assign('email','[email protected]');
        $this->assign('time',time());
        $this->assign('user','cjk');
        return $this->fetch();
    }
}

在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>

猜你喜欢

转载自blog.csdn.net/weixin_38468437/article/details/81606105