Voodoo\Core\Http\Response::redirect PHP Метод

redirect() публичный статический Метод

public static redirect ( $url, $httpCode = 302 )
    public static function redirect($url, $httpCode = 302)
    {
        self::setHeader("Location: {$url}", $httpCode);
        exit;
    }

Usage Example

Пример #1
0
 /**
  * To redirect the page to a new page
  * @param string $path
  * @param int $httpCode
  */
 public function redirect($url = "", $httpCode = 302)
 {
     if (!$url) {
         $url = $this->getControllerUrl();
     }
     if (preg_match("/^http/", $url)) {
         // http://xyz
         $url = $url;
     } else {
         if (preg_match("/^\\//", $url)) {
             // we'll add the ? if possible
             $url = $this->getBaseUrl() . $url;
         } else {
             // go to the current module
             $url = $this->getModuleUrl() . "/{$url}";
         }
     }
     $this->abort();
     return Http\Response::redirect($url, $httpCode);
 }