php 自制简单路由类 望大神指点

class route{    /** @var null  模块 */    private static $module = null;    /** @var null 控制器 */    private static $controller = null;    /** @var null 方法 */    private static $action = null;    /** @var  控制器url */    private static $controllerPath;

/**     * route constructor.     * @param array $config url     */    public function __construct($config = [])    {        $var_parse = explode(‘/‘, $config[‘r‘]);        if (count($var_parse) == 3){            self::$module = $var_parse[0];            self::$controller = ucwords($var_parse[1]).‘Controller‘;            self::$action = $var_parse[2];            self::$controllerPath = APP_ROOT.‘/controllers/‘.self::$module.‘/‘.self::$controller.‘.php‘;        }elseif(count($var_parse) == 2){            self::$controller = ucwords($var_parse[0]).‘Controller‘;            self::$action = $var_parse[1];            self::$controllerPath = APP_ROOT.‘/controllers/‘.self::$controller.‘.php‘;        }    }

/**     * 执行控制器方法     * @return null     */    public static function run(){        self::register();        $controller = new self::$controller;        if(method_exists($controller, self::$action)){            $action = self::$action;            $controller->$action();        }else{            header("HTTP/1.1 404 Not Found");        }    }

/**     * 加载类     */    public static function register(){        spl_autoload_register("self::loadClass");    }

//自动加载    public static function loadClass(){        if(!file_exists(self::$controllerPath)){            header("HTTP/1.1 404 Not Found");        }        require_once self::$controllerPath;    }}
时间: 2024-08-08 13:54:00

php 自制简单路由类 望大神指点的相关文章

自己封装了一个EF的上下文类.,分享一下,顺便求大神指点

using System; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Data.Entity; using System.Data.Entity.Core.Objects; using System.Data.Entity.Infrastructure; using System.Data.Entity.Migrations; using System

耐克的定制页用canvas如何实现....跪求前端大神指点。

选择鞋子的鞋底 鞋底会变色,也可以添加自己定制的id,这个东西看的是用canvas做的,但是小弟确实不知道怎么去做,求大神指点一二,不胜感激! nike的定制页地址:http://store.nike.com/cn/zh_cn/product/air-presto-id/?piid=41054&pbid=1045075390#?pbid=1045075390

dll注册到GAC还是bin - 跪求大神指点 - sharepoint程序

通常来说程序在使用dll的时候,会先去GAC中查找是否有存在合适的dll,然后才会到应用程序下的bin目录去查找: 前几天遇到了一个奇葩问题,web项目工程添加了一个第三方dll的引用,然后把这个第三方的dll注册到了GAC里面,但是web程序在运行时,报错程序集未引用:然后就在bin目录下也copy了一份dll,然后程序就OK了:但是这个情况推翻了上面的逻辑,于是进行了多次测试修改,终于发现,如果在前台页面(aspx页面)中调用了第三方dll中的方法(<%%>的方式调用),则此第三方dll就

ssh2整合: No bean named &#39;sessionFactory&#39; is defined(求大神指点)

applicationContext.xml 中已经配置 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="dataSource" ref="dataSource"/> <property name="hibernate

最近学到的知识概述,求大神指点后续的路该怎么规划

求大神指导迷津: 前端的路,已经走了一年多了,从懵懂地编码到现在的熟悉的操作,学会使用了svn.git.webstrom这些版本控制和开发软件,尤其是当学会用webstrom进行git提交代码时,才很惊喜的发现,学会使用好用的工具可以节省很多时间,大大提升工作的效率![工具很重要]. 在搭建好的框架下,去开发设计好的网页图,对我来说都是没问题的了,前段时间,在没有人指导的情况下,自己摸索着在现有的框架下,调用ztree完成一个功能,包括API接口该如何设计.保存后如何向后台传数据.[自学能力在成

页面显示多个计时器,有开始暂停按钮来控制倒计时的开关????求大神指点

是这样的,项目需要一个这样的效果我先上个图 需求是这样的,从数据库获取来的列表,组装时间换算成分钟,点击开始时换算成时分秒的格式倒计时,点击暂停按钮停止倒计时,向后台发送原因,可以开启多个倒计时,可以暂停任意一个,还可以点击开始后继续倒计时, 大神们,这可真难着了,这到底该怎么玩呢??? 这个需求是销售公司规定员工在规定时间内完成组装便可以得到奖励金,超过便没有,该怎么实现呢???

用Properties类创建对象读取文档*txt格式书写ATM简单版本,看大神们有什么改进的,欢迎交流

先创建了一个ATM.txt格式的的文档,将卡的账号.密码.内存金额放在此文档 password=123money=5000userName=123 然后用类Properties创建一个对象,将银行卡的属性放进对象中,书写一个简单的ATM机实现简单的登录.存款.取款.查看.修改密码.退出程序等功能具体代码示例如下:package unit331; import java.io.FileReader; import java.io.FileWriter; import java.util.Prope

简易计算器,欢迎大神指点 改进

<!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title></title> <script type="text/javascript"> onload = function() { document.getElementById('add').onclick = function(){ var iNum1 = docume

SpringMVC Validation验证(帖子最后有个问题,麻烦大神指点一下)

package com.domain; import java.io.Serializable; public class User implements Serializable { private String loginname; private String password; public String getLoginname() { return loginname; } public void setLoginname(String loginname) { this.login