测试路由如下:注意,本案例只可用于学习,请勿直接使用在真实项目之中
访问路由如下:
index.php/
index.php/asd/
index.php/b/
index.php/i/z/1/2
index.php/i/x/3/4
index.php/i/c/5/6
- <?php
- /*
- +----------------------------------------------------------------------
- + Title : 路由器 单一入口
- + Author : 小黄牛
- + Version : V1.0.0.1
- + Initial-Time : 2016-10-17 11:24
- + Last-time : 2016-10-17 11:24 + 小黄牛
- + Desc : 从这里实现路由监听
- +----------------------------------------------------------------------
- */
- # 声明页面编码
- header("Content-type: text/html; charset=utf-8");
- # 引入路由器
- require 'Router.class.php';
- # 引入路由子类
- require 'Route.class.php';
- # 引入对应的测试路由类
- require 'Ceshi.php';
- # 加载路由监听
- Route::Any('',function(){
- echo '这是默认入口的路由';
- });
- # 闭包路由
- Route::Any('b/',function(){
- echo '这下牛逼了';
- });
- # 默认路由
- Route::Any('asd/',function(){
- echo '11111111';
- });
- # 不是闭包路由
- Route::Any('i/z','id/name','ceshi/Add');
- Route::Any('i/x','id/name','test/index');
- Route::Any('i/c','id/name','index/index');
访问路由如下:
index.php/
index.php/asd/
index.php/b/
index.php/i/z/1/2
index.php/i/x/3/4
index.php/i/c/5/6
友情提示:垃圾评论一律封号...