时时商务社区

标题: PHP url的pathinfo模式加载不同控制器的简单实现 [打印本页]

作者: 阿情    时间: 2018-2-14 05:33

            使用自动加载和解析url的参数,实现调用到不同的控制器,实现了pathinfo模式和普通的url模式
文件结构:
|--Controller
  |--Index
    |--Index.php
|--Application.php
Application.php
3){
              if($i%2==0){
                $_GET[$key]=$value;
              }
            }
            break;
        }
      }
    }
    $_GET['m']=!empty($_GET['m']) ? ucfirst($_GET['m']) : 'Index';
    $_GET['c']=!empty($_GET['c']) ? ucfirst($_GET['c']) : 'Index';
    $_GET['a']=!empty($_GET['a']) ? $_GET['a'] : 'index';
    $class="\\Controller\\{$_GET['m']}\\{$_GET['c']}";
    $controller=new $class;
    $controller->$_GET['a']();
  }
}
Application::main();
\Controller\Index\Index.php
效果:

以上这篇PHP url的pathinfo模式加载不同控制器的简单实现就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
            
            
您可能感兴趣的文章:
  • 让Nginx支持ThinkPHP的URL重写和PATHINFO的方法分享
  • PHP pathinfo()获得文件的路径、名称等信息说明
  • 在nginx中配置pathinfo模式支持thinkphp的URL重写
  • Nginx隐藏index.php和Pathinfo模式配置例子
  • nginx+thinkphp下解决不支持pathinfo模式
  • Ubuntu下Nginx配置ThinkPHP的Pathinfo和URl Rewrite模式
  • Nginx配置PATHINFO隐藏thinkphp index.php
  • PHP命令行执行整合pathinfo模拟定时任务实例
  • php使用函数pathinfo()、parse_url()和basename()解析URL
  • 详解PHP中pathinfo()函数导致的安全问题
            




    欢迎光临 时时商务社区 (http://bbs.4435.cn/) Powered by Discuz! X3.2