TP5.1 How to use functions in view (code)

不言
Release: 2023-04-03 20:44:01
Original
7129 people have browsed it


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(&#39;email&#39;,&#39;1047588430@qq.com&#39;);
        $this->assign(&#39;time&#39;,time());
        $this->assign(&#39;user&#39;,&#39;cjk&#39;);
        return $this->fetch();
    }
}
Copy after login

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>
Copy after login

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!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template