zoukankan      html  css  js  c++  java
  • thinkphp路由配置route.php

    路由设置配置

    打开route.php 
    引入Route控制器类(use thinkRoute;)
    设置路由--》  Route::rule('路由表达式','路由地址','请求类型','路由参数(数组)','变量规则(数组)');

    静态路由例子:

    1.                         use thinkRoute;
    2. // 注册路由到index模块的News控制器的read操作
    3. Route::rule('new/:id','index/News/read');
    4. 访问http://serverName/new/5 直接路由到到http://serverName/index/news/read/id/5

                    动态带参数路由:

    1.                 Route::rule('course/:id','index/index/course');
    2. // 批量注册GET路由
    3. Route::rule([
    4. '路由规则1'=>'路由地址和参数',
    5. '路由规则2'=>['路由地址和参数','匹配参数(数组)','变量规则(数组)']
    6. ...
    7. ],'','请求类型','匹配参数(数组)','变量规则');
    8. Route::get([
    9. 'new/:id' => 'News/read',
    10. 'blog/:id' => ['Blog/edit',[],['id'=>'d+']]
    11. ...
    12. ]);
    13. // 效果等同于
    14. Route::rule([
    15. 'new/:id' => 'News/read',
    16. 'blog/:id' => ['Blog/edit',[],['id'=>'d+']]
    17. ...
    18. ],'','GET');
    19. //等同于any方式
    20. return [
    21. 'new/:id' => 'News/read',
    22. 'blog/:id' => ['Blog/update',['method' => 'post|put'], ['id' => 'd+']],
    23. ];




  • 相关阅读:
    252个基本词根详解
    记忆宫殿|一个故事轻松记忆常见252个英语字根(190~252)
    海外旅游最常用的100句英语口语
    与老外见面的10大经典句
    ReportManager
    ContextLoader
    Workflow License invalid!!
    JD-GUI
    DJ Java Decompiler
    AndroChef Java Decompile
  • 原文地址:https://www.cnblogs.com/showcase/p/11827391.html
Copyright © 2011-2022 走看看