您当前的位置: 首页 > 慢生活 > 程序人生 网站首页程序人生
webman-快速開始-簡單示例-返回視圖
发布时间:2022-01-16 20:50:53编辑:雪饮阅读()
返回視圖,一般同控制器路徑有對應關係,這裏以上次返回jsonp時候控制器爲例,則其對應hello方法實現如:
$default_name = 'webman';
$name = $request->get('name', $default_name);
return view('user/hello', ['name' => $name]);
然後在同app/view中建立user目錄在user目錄中建立hello.html如:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>webman</title>
</head>
<body>
hello <?=htmlspecialchars($name)?>
</body>
</html>
重啓webman就實現了返回視圖,此時瀏覽器訪問如:
http://192.168.43.170:8787/user/hello?name=tom
就會返回上面這個視圖渲染之後的頁面。
关键字词:webman,返回視圖