app\index\controller\Index.html
<?php namespace app\index\controller; use think\Controller; class Index extends Controller { public function index() { // template variable assignment $username = 'chaoyi'; $this -> assign('username',$username); /** * Render template output * First parameter: template file * Second parameter: template variable (array) * Third parameter: template replacement (array) */ return $this->fetch('index',[ 'email' => '[email protected]', 'dictum' => 'Always focused on the website' ],[ 'always' => 'forever' ]); } }
app\index\view\index\index.html
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"> <title>As always</title> </head> <body> <p>My name: {$username}</p> <p>My email: {$email}</p> <p>My slogan: {$dictum}</p> </body> </html>
Effect picture: