当前位置: 首页>>代码示例>>PHP>>正文


PHP Routes::addRoute方法代码示例

本文整理汇总了PHP中Routes::addRoute方法的典型用法代码示例。如果您正苦于以下问题:PHP Routes::addRoute方法的具体用法?PHP Routes::addRoute怎么用?PHP Routes::addRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Routes的用法示例。


在下文中一共展示了Routes::addRoute方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRoutes

    public static function getRoutes()
    {
        return self::$routes;
    }
    public static function getPath($controller, $action, $absolute = true)
    {
        if ($absolute) {
            return $_SERVER['REMOTE_HOST'] . self::$routes_inverse[$controller . "_" . $action];
        } else {
            return self::$routes_inverse[$controller . "_" . $action];
        }
    }
    public function addRoute($path, $httpMethod, $controller, $action, $format = "html")
    {
        self::$routes[$path . "__" . $httpMethod . "__" . $format] = [$controller, $action];
        self::$routes_inverse[$controller . "_" . $action] = $path;
    }
}
Routes::addRoute("/", "GET", "Site", "index");
Routes::addRoute("/login", "GET", "Site", "login");
Routes::addRoute("/register", "GET", "Site", "register");
Routes::addRoute("/logout", "GET", "User", "logout");
Routes::addRoute("/cart/buy", "GET", "Transaction", "buy");
Routes::addRoute("/cart/checkout", "POST", "Transaction", "checkout");
Routes::addRoute("/cart/history", "GET", "Transaction", "history");
Routes::addRoute("/user/register", "POST", "User", "register");
Routes::addRoute("/postlogin", "POST", "Site", "postLogin");
Routes::addRoute("/postregister", "POST", "Site", "postRegister");
Routes::addRoute("/user/edit", "GET", "User", "edit");
Routes::addRoute("/user/save", "POST", "User", "save");
开发者ID:medo,项目名称:elmasla7a,代码行数:30,代码来源:Routes.php


注:本文中的Routes::addRoute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。