protected function redirect($url, $code = 302)
    {
        if (!headers_sent()) {
            if (SERVER_MODE === 'swoole' ) {
                $GLOBALS['__$response']->status($code);
            } else if ($code == 301) {
                header('HTTP/1.1 301 Moved Permanently');
            } else {
                header('HTTP/1.1 302 Found');
            }

            $this->setHeader("Location", $url);
            $this->stopRun();
        } else {
            echo '<html><head><meta charset="UTF-8" /><title></title></head><body>';
            echo '<script>window.location.href="'. $url .'";</script></body></html>';
            $this->stopRun();
        }
    }
protected function redirect($url, $code = 302)
    {
        if (!headers_sent()) {
            if (SERVER_MODE === 'swoole' ) {
                $GLOBALS['__$response']->status($code);
            } else if ($code == 301) {
                header('HTTP/1.1 301 Moved Permanently');
            } else {
                header('HTTP/1.1 302 Found');
            }

            $this->setHeader("Location", $url);
            $this->stopRun();
        } else {
            echo '<html><head><meta charset="UTF-8" /><title></title></head><body>';
            echo '<script>window.location.href="'. $url .'";</script></body></html>';
            $this->stopRun();
        }
    }
protected function redirect ( $ url , $ code = 302 ) { if ( ! headers_sent ( ) ) { if ( SERVER_MODE === 'swoole' ) { $ GLOBALS [ '__$response' ] -> status ( $ code ) ; } else if ( $ code == 301 ) { header ( 'HTTP/1.1 301 Moved Permanently' ) ; } else { header ( 'HTTP/1.1 302 Found' ) ; } $ this -> setHeader ( "Location" , $ url ) ; $ this -> stopRun ( ) ; } else { echo '<html><head><meta charset="UTF-8" /><title></title></head><body>' ; echo '<script>window.location.href="' . $ url . '";</script></body></html>' ; $ this -> stopRun ( ) ; } }
Redirect to url
Compatible swoole mode server container

@param string $url
@param int $code 301 or 302
@return void
Redirect to url Compatible swoole mode server container