Correcting teacher:天蓬老师
Correction status:qualified
Teacher's comments:之前咱们学到类似的框架原理, laravel只不过是一个放大版的mvc
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>测试手动创建</title>
</head>
<body>
<div>用户名为:{{$yhm}}</div>
<div>用户名是:<?php echo e($yhm); ?></div>
<div>用户名:<?php echo e($yhm) ;?></div>
<div>英文名:{!!$name!!}</div>
<div>年龄:<?php echo e($age) ;?></div>
<a href="http://www.php.cn" target="_blank">php中文网</a>
</body>
</html>
<?php
namespace App\Http\Controllers;
Class Home extends Controller{
public function index(){
echo 'she is home->index';
}
public function php(){
// return 'this is melind';
$username = '米亚';
$data = ['yhm'=>$username,'name'=>'miya','age'=>20];
$data['yhm'] = $username;
$data['name'] = '<span style="color:red;">miya</span>';
$data['age'] = 18;
return view('test',$data);
// return view('test',['bl'=>$username]);
}
}
<?php
Route::get('/', function () {
return view('test');
});
// 控制器到路由,如何映射刚才写的home.php里的内容?
//要用@符号,指向index()或php()方法
Route::get('/home.html','Home@index');
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>测试手动创建</title>
</head>
<body>
<div>
@if($yhm)
<div>用户名字是:{{$yhm}}</div>
@else
<a href="">登录</a>
@endif
</div>
<div>用户名为:{{$yhm}}</div>
<div>用户名是:<?php echo e($yhm); ?></div>
<div>用户名:<?php echo e($yhm) ;?></div>
<div>英文名:{!!$name!!}</div>
<div>年龄:<?php echo e($age) ;?></div>
<a href="http://www.php.cn" target="_blank">php中文网</a>
<div>
@switch($age)
@case(15)
<div style="color: red;">未成年</div>
@break
@case(18)
<div style="color: green;">成年了</div>
@break
@endswitch
</div>
</body>
</html>