Skip to content

PHP Helpers: redirect_url

12 Feb 2010

New function: redirect_url

if ( !function_exists( 'redirect_url' ) ) {
    function redirect_url( $url, $status = 302 ) {
        header( "Location: {$url}", TRUE, $status );
        exit;
    }
}

A special case wrapper around the header function to do URL redirection. I specifically added the exit call inside the function so that redirect happens immediately. That way I don’t have a chance to forget about it later on :-)

Related posts:

  1. PHP Helpers: esc_html
  2. PHP Helpers: debug_log
  3. PHP Helpers: curl_http_request
  4. PHP Helpers: html_print_r
  5. PHP Helpers: make_slug

From → Posts

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS