fastadmin 的通过配置index.php实现电脑和手机访问分别显示不同的页面

    1.// 加载框架引导文件 

      $user_agent = $_SERVER['HTTP_USER_AGENT'];

    2.//定义应用目录

      define('APP_PATH', __DIR__ . '/../application/');

    3.// 加载框架引导文件

      require __DIR__ . '/../thinkphp/base.php';

    4.// 绑定到模块

      if(stristr($user_agent,'iPad')) {
            \think\Route::bind('index');
      }else if(stristr($user_agent,'Android')) {
            \think\Route::bind('mobile');
      }else if(stristr($user_agent,'iPhone')){
            \think\Route::bind('mobile');
      else{
            \think\Route::bind('index');
      }
    5.// 关闭路由
      \think\App::route(false);

    6.// 设置根url

      \think\Url::root('');
    7.// 执行应用
      \think\App::run()->send();
 
 
 
 
 
 

 

posted @ 2020-11-30 13:47  时光cs流逝  阅读(848)  评论(0编辑  收藏  举报