當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Uri::routedsegments方法代碼示例

本文整理匯總了PHP中Uri::routedsegments方法的典型用法代碼示例。如果您正苦於以下問題:PHP Uri::routedsegments方法的具體用法?PHP Uri::routedsegments怎麽用?PHP Uri::routedsegments使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Uri的用法示例。


在下文中一共展示了Uri::routedsegments方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: call_user_func

    // with an underscore can be called via the URI.
    if (array_key_exists(strtolower($method), Core::libraries()) || substr($method, 0, 1) == '_') {
        Core::error404($uri);
    }
    // instantiate the controller (and run its constructor)
    $class = Core::controller($class);
    // Call the remapping function if it's present in the controller
    if (method_exists($class, '_remap')) {
        call_user_func(array($class, '_remap'));
    } else {
        if (!method_exists($class, $method)) {
            Core::error404($uri);
        }
        // Call the requested method. Any URI segments present
        // (besides the controller/action) will be passed to the method for convenience
        call_user_func_array(array($class, $method), array_slice(Uri::routedsegments(), 2));
    }
    // send final output
    Output::display();
}
// -------------------------------------------------------------  Support Functions
function urlpath($url)
{
    return str_replace(URL, ROOT, $url);
}
function rmroot($path)
{
    return str_replace(ROOT, '', $path);
}
function error($msg)
{
開發者ID:hectormenendez,項目名稱:h23,代碼行數:31,代碼來源:index.php

示例2: _set

 /**
  *  SET THE ROUTE
  *  This function takes an array of URI segments as
  *  input, and sets the current class/method
  **/
 private static function _set($segments = false)
 {
     // we check the segments array
     $segments = self::_validate($segments);
     if (count($segments) == 0) {
         return;
     }
     self::$_CLS = $segments[0];
     // Set the corresponding method.
     if (isset($segments[1])) {
         self::$_MTD = $segments[1];
     } else {
         self::$_MTD = $segments[1] = 'index';
     }
     // Update the routed segments array
     // if there's no custom routing this will be the same as Uri::segments();
     Uri::routedsegments($segments);
 }
開發者ID:hectormenendez,項目名稱:h23,代碼行數:23,代碼來源:router.php


注:本文中的Uri::routedsegments方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。