###*路由方法匹配函数*
* * * * *
~~~
/**
* @param array $method get\post\ajax方法(匹配多);
*
* @param string $param 匹配单个,将传参以\分割与当前url参数数组匹配
* @param array $param 匹配多个
*
* @param string $func 调用对应类对应方法
* @param \Closure $func 调用函数,并传参$args
*
* @param bool $aiload 是否智能加载需要类文件(默认否,在一个类方法或函数加载类文件过多的时候使用)
*
* @return void
*/
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**
~~~
/**
* @example
*/
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']
~~~
###*方法匹配实例*
* * * * *
~~~
/**
* @example
* 配合路由规则,匹配空字符
* 调用函数...
*/
Route::get(':empty', function () {
code......
});
/**
* @example
* 匹配index
* 调用当前 命名空间//Index类的index方法
*/
Route::get('index','Index@index');
/**
* @example
* 匹配test
* 调用当前命名空间//Index类的test方法
*/
Route::get('test','Index@test');
/**
* @example
* 匹配empty
* 调用方法
* 传参1
*/
Route::get('empty',function(int $number){
echo $number;
},[1]);
/**
* @example
* 匹配page/id/:int(路由规则)
* 调用当前命名空间//Index类page方法
* 传参$_GET['id'],必定为路径中这个id;
*/
Route::get('page/id(:int)', 'Index@page@?id');
/**
* @example
* 匹配edit
* 调用当前命名空间//Index类edit方法
* 传参$_POST['test']
*/
Route::post('edit', 'Index@edit@#text');
~~~
- 序言
- 框架
- 框架获取
- 框架安装
- 应用结构
- 框架结构
- 应用目录结构
- 框架流程
- 命名规范
- 核心思想
- 扩展
- 类组装
- 框架基类
- Arr
- Arr扩展函数
- Date基类
- Dir
- Dir基类扩展函数
- Dom基类
- File基类
- Str基类
- Str随机字符
- Str操作函数
- Str随机创建
- Html基类
- Header基类
- Filter基类
- 框架核心
- 路由
- 路由信息
- 路由安装样本
- 路由逻辑原理
- 路由方法匹配
- 路由分组
- 路由构建
- 路由限制
- 路由规则
- 路由多语,多主题
- 路由常量
- 路由扩展
- 路由例
- 路由真静态使用
- 智能加载
- Response基类
- 定时任务
- 框架主类
- 控制器
- model
- model样本
- model使用
- view
- view路径
- view方法
- view配置
- view使用
- view真静态
- view例
- view多主题
- 模版引擎
- 模版引擎之单句解析
- 模版引擎之foreach解析
- cache
- cache注意事项
- cache配置
- cache方法
- cache使用
- cache扩展
- cache处理类File配置
- cache处理类Apc,Apcu配置
- cache处理类memcache,memcached配置
- cookie
- session
- 框架扩展
- Upload类
- 测试
- 测试流程
- 测试文件编写
- 测试文件例-数组篇
- 测试类函数
- 测试类使用
- 测试注意事项
- 常用功能
- 读码须知
- 个人技巧或习惯
- 万能get,call,callStatic
- &&和||
- 变量值交换
- trait拼接
- 多语支持