thinkphp中路由的基本使用

1.在application中下的config.php中

以下代码改为true

 // 是否开启路由
    'url_route_on'           => true,
 // 是否强制使用路由
    'url_route_must'         =>true,

2.然后在route.php中定义路由

ps:把初始化的那些代码删除,不然无法使用路由          注意一定要加上 use think\Route;

<?php

use think\Route;

Route::get('/home/:name',function ($name){
    return '你的姓名是:'.$name;
});

放一张图显示结果 注意路由的写法

 

posted @ 2020-02-12 13:40  以己为镜  阅读(332)  评论(0编辑  收藏  举报