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


PHP Basic::safeUrl方法代碼示例

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


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

示例1: __construct

 protected function __construct()
 {
     if (isset($_SERVER['REQUEST_URI'])) {
         $this->full_url_path = $_SERVER['REQUEST_URI'];
     } elseif (isset($_SERVER['argv'])) {
         $this->full_url_path = $_SERVER['PHP_SELF'] . '?' . $_SERVER['argv'][0];
     } else {
         $this->full_url_path = $_SERVER['PHP_SELF'] . '?' . $_SERVER['QUERY_STRING'];
     }
     $pos = strpos($this->full_url_path, '?');
     if ($pos === false) {
         $this->url_get = '';
         $this->url_path = $this->full_url_path;
     } else {
         $this->url_get = substr($this->full_url_path, $pos + 1);
         $this->url_path = substr($this->full_url_path, 0, $pos);
     }
     //把連續的“\"或“/”替換成一個“/”
     $this->url_path = preg_replace('/[\\/\\\\]+/', '/', $this->url_path);
     //去掉末尾的斜杠
     $this->url_path = substr($this->url_path, -1) == '/' ? substr($this->url_path, 1, -1) : substr($this->url_path, 1);
     $array_urlPath = array();
     if ($this->url_path) {
         $pos = strpos($this->url_path, '/');
         if ($pos === false) {
             $array_urlPath = array(0 => $this->url_path);
         } else {
             $array_urlPath = explode('/', $this->url_path);
         }
     }
     $this->controllerName = isset($array_urlPath[0]) ? strtolower($array_urlPath[0]) : 'index';
     $this->actionName = isset($array_urlPath[1]) ? strtolower($array_urlPath[1]) : 'index';
     //獲得並設置參數
     $this->array_parameter = array();
     if (($arrayCount = count($array_urlPath)) > 2) {
         for ($i = 2; $i < $arrayCount; ++$i) {
             $this->array_parameter[] = Basic::safeUrl($array_urlPath[$i]);
         }
     }
     if (!Singleton::getInstance('RequestModule')->isPost()) {
         $this->checkUrl();
     }
 }
開發者ID:sujinw,項目名稱:php-lugit-framework,代碼行數:43,代碼來源:Router.php


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