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


PHP Q_Response::redirected方法代码示例

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


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

示例1: redirect

 /**
  * Sets a header to redirect to a given URI or URL.
  * @method redirect
  * @static
  * @param {string} $uri The URL or internal URI to redirect to
  * @param {array} $options An array of options that can include:
  *  "loop" => Defaults to false. If true, sets the redirect header even if the current URL is the same.
  *  "noProxy" => Defaults to false. If true, doesn't use the proxy mapping to determine URL
  *  "permanently" => If true, sets response code as 304 instead of 302
  * @param {boolean} [$noProxy=false]
  * @return {boolean}
  *  Return whether the redirect header was set.
  */
 static function redirect($uri, $options = array())
 {
     extract($options);
     $url = Q_Uri::url($uri, null, !empty($noProxy));
     if ($url === Q_Uri::unreachableUri()) {
         throw new Q_Exception_BadValue(array('internal' => 'uri', 'problem' => 'no url routes to it'));
     }
     $level = ob_get_level();
     for ($i = 0; $i < $level; ++$i) {
         ob_clean();
     }
     /**
      * @event Q/response {before}
      * @param {string} permanently
      * @param {string} uri
      * @param {string} url
      * @param {string} loop
      * @return {boolean}
      */
     $result = Q::event('Q/redirect', compact('uri', 'url', 'loop', 'permanently', 'noProxy', 'level'), 'before');
     if (isset($result)) {
         return $result;
     }
     if (!empty($loop) and Q_Request::url() === $url) {
         return false;
     }
     if (!Q_Request::isAjax()) {
         if (!empty($permanently)) {
             header("HTTP/1.1 301 Moved Permanently");
         }
         header("Location: {$url}");
     }
     self::$redirected = $uri;
     return true;
 }
开发者ID:dmitriz,项目名称:Platform,代码行数:48,代码来源:Response.php


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