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


PHP Q_Request::app_root_url方法代码示例

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


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

示例1: baseUrl

 /**
  * Get the base URL, possibly with a controller script
  * @method baseUrl
  * @static
  * @param {boolean} [$with_possible_controller=false] If this is true, and if the URL contains 
  *  the controller script, then the controller script is included 
  *  in the return value. You can also pass a string here, which
  *  will then be simply appended as the controller.
  */
 static function baseUrl($with_possible_controller = false)
 {
     if (isset(self::$base_url)) {
         if (is_string($with_possible_controller)) {
             if (empty($with_possible_controller)) {
                 return self::$app_root_url;
             }
             return self::$app_root_url . "/" . $with_possible_controller;
         }
         if ($with_possible_controller) {
             return self::$base_url;
         }
         return self::$app_root_url;
     }
     if (isset($_SERVER['SERVER_NAME'])) {
         // This is a web request, so we can automatically determine
         // the app root URL. If you want the canonical one which the developer
         // may have specified in the config field "Q"/"web"/"appRootUrl"
         // then just query it via Q_Config::get().
         // Infer things
         self::$controller_url = self::inferControllerUrl($script_name);
         // Get the app root URL
         self::$app_root_url = self::getAppRootUrl();
         // Automatically figure out whether to omit
         // the controller name from the url
         self::$controller_present = 0 == strncmp($_SERVER['REQUEST_URI'], $_SERVER['SCRIPT_NAME'], strlen($_SERVER['SCRIPT_NAME']));
         // Special case for action.php controller
         // in case a misconfigured web server executes index.php even though
         // a url of the form $base_url/action.php/... was requested,
         // we will try to detect action.php anyway, and set it accordingly
         $slashpos = strrpos($script_name, '/');
         $action_script_name = ($slashpos ? substr($script_name, 0, $slashpos) : '') . '/action.php';
         if (0 == strncmp($_SERVER['REQUEST_URI'], $action_script_name, strlen($action_script_name))) {
             self::$controller_url = substr(self::$controller_url, 0, strrpos(self::$controller_url, '/')) . '/action.php';
             self::$controller_present = true;
             Q::$controller = 'Q_ActionController';
         }
         // Set the base url
         self::$base_url = self::$controller_present ? self::$controller_url : self::$app_root_url;
     } else {
         // This is not a web request, and we absolutely need
         // the canonical app root URL to have been specified.
         $ar = Q_Config::get('Q', 'web', 'appRootUrl', false);
         if (!$ar) {
             throw new Q_Exception_MissingConfig(array('fieldpath' => 'Q/web/appRootUrl'));
         }
         $cs = Q_Config::get('Q', 'web', 'controllerSuffix', '');
         self::$app_root_url = $ar;
         self::$controller_url = $ar . $cs;
         self::$controller_present = false;
         self::$base_url = self::$app_root_url;
     }
     if (is_string($with_possible_controller)) {
         return self::$app_root_url . "/" . $with_possible_controller;
     }
     if ($with_possible_controller) {
         return self::$base_url;
     }
     return self::$app_root_url;
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:69,代码来源:Request.php


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