首页 > 作文

Laravel框架路由管理简单示例

更新时间:2023-04-07 10:09:55 阅读: 评论:0

本文实例讲述了laravel框架路由管理。分享给大家供大家参考,具体如下:

路由中输出视图

route::get('/', function () {  return view('welcome');});

get路由请求

route::get('get',function(){  r点法式eturn 'get路由请求';});

post路由请求

route::post('post',function(){  return 'post请求';});

多路由请求

route::match(['get','post'],'match',function(){  return '多路由请求';});

任意路由请求

route::any('any',function(){  return '任意路由请求';});

路由参数

route::get('ur/{id}',function($id包河公园){  return 'ur-id-'.$id;});

路由参数默认值

route::get('ur/{name?}',function($name = 'yxh'){  return 'ur中国地理常识-name-'.$name;});

路由参数的正则验证

route::get('ur/{id}/{name?}',function($id,$name = 'yxh'){  return 'ur-id-'.$id.'-name-'.$name;})->where(['id'=>'[0-9]+','name'=>'[a-za-z]+']);

路由别名

route::get('ur/member-center',['as'=>'center',function(){  return route('center');}]);

路由群组

route::group(['prefix'=>'member'],function(){  //路由别名  route::get('ur/member-center',['as'=>'center',function(){    return route('center');  }]);  //任意路由请求  route::any('any',function(){    return '任意路由请求';  });});

路由中输出视图

route::get('view',function(){  return view('welcome');});

关联控制器

route::get('member/info','membercontroller@info');route::get('test','urcontroller@test');route::get('query','urcontroller@query');route::get('orm','urcontroller@orm');route::get('ction1',['us'=>'urcontroller@ction1']);两个黄鹂鸣翠柳route::get('url',['as'=>'url','us'=>'urcontroller@urltest']);

更多关于laravel相关内容感兴趣的读者可查看本站专题:《laravel框架入门与进阶教程》、《php优秀开发框架总结》、《php面向对象程序设计入门教程》、《phpdnf黑暗武士刷图加点+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于laravel框架的php程序设计有所帮助。

本文发布于:2023-04-07 10:09:53,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/zuowen/3dbd134b68975bed21151b7e38ffc7d3.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

本文word下载地址:Laravel框架路由管理简单示例.doc

本文 PDF 下载地址:Laravel框架路由管理简单示例.pdf

标签:路由   框架   参数   别名
相关文章
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图