栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > PHP > php开源框架 > msqphp

路由方法匹配 - msqphp轻量级php7.1框架beta -1.9版本使用手册

msqphp 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

路由方法匹配 - msqphp轻量级php7.1框架beta -1.9版本使用手册


###*路由方法匹配函数*

* * * * *



Route::get($param, $func, array $args = [], bool $aiload = false) : void;
Route::post($param, $func, array $args = [], bool $aiload = false) : void;
Route::ajax($param, $func, array $args = [], bool $aiload = false) : void;

Route::method(array $method, $param, $func, array $args = [], bool $aiload = false) : void;


###*参数匹配*
* * * * *
格式:
+ **string**
+ **string(string)/value_name(roule)/value_name(roule)**
+ **string(string)@?get1(roule)&get2(roule)**
+ **string(string)@#post1(roule)&post1(roule)**
+ **string(string)@#post1(roule)?get1(roule)**
+ **string(string)/value_name(roule)/...@?id(roule)&...#name(roule)&...**

> 注解
第一个string为定值匹配
之后value_name按照括号中对应路由规则匹配
匹配成功则添置get参数中,名称为value_name,优先级最高,覆盖正常get传参
@之后为get或post参数检测,?接get#接post,&连接,括号中为检测规则

//例:
Route::get('novel/novel(string)/number(int), 'View@showNovel@?novel&number');
//匹配novel/任意字符串(路由规则string)/任意数字(路由规则int)
//www.example.com/novel/ceshixiaoshuo/1
//调用View->showNovel('ceshixiaoshuo',1);




###*类函数传参*
* * * * *
格式:
+ **class@method**
+ **class@method@?get1&get2**
+ **class@method@#post1&post2**
+ **class@method[@?get1&get2#post1&post2]**

**如果不存在则传值null**


Index@index ----> 当前命名空间//Index类index方法
Index@index@?id&name ----> 并传递$_GET['id'],$_GET['name']
Index@index@#id&name ----> 并传递$_POST['id'],$_POST['name']
Index@index@?id#name ----> 并传递$_GET['id'],$_POST['name']


###*方法匹配实例*
* * * * *


Route::get(':empty', function () {
code......
});


Route::get('index','Index@index');


Route::get('test','Index@test');


Route::get('empty',function(int $number){
echo $number;
},[1]);



Route::get('page/id(:int)', 'Index@page@?id');



Route::post('edit', 'Index@edit@#text');


转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/213930.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号