CI3在路由规则中使用回调函数来处理逆向引用

 

 创建yy类

class yy extends CI_Controller
{

  public function __construct()
  {
    parent::__construct();
  }

  public function fy()
  {
    echo 'home/yy';
  }

  public function fy2()
  {
    echo 'home/yy2';
  }
}

 

$route['hh/(:num)/(:num)'] = function ($dd, $ee) {
    print_r($dd);
    echo '<br>';
    print_r($ee);
    echo '<br>';
    if ($dd == 1)
        return 'home/yy/fy';
    if ($dd == 2)
        return 'home/yy/fy2';
};

访问

http://www.ci3.com/hh/1/55

获得结果

 

posted @ 2024-09-06 09:30  哆啦阿梦  阅读(18)  评论(0)    收藏  举报