Scroll to top

How to Alternative to “header” for re-directs in PHP

Alternative to “header” for re-directs in PHP

function redirect($url)
{
    if (!headers_sent())
    {   
        header(‘Location: ‘.$url);
        exit;
        }
    else
        { 
        echo ‘<script type=”text/javascript”>’;
        echo ‘window.location.href=”‘.$url.'”;’;
        echo ‘</script>’;
        echo ‘<noscript>’;
        echo ‘<meta http-equiv=”refresh” content=”0;url=’.$url.'” />’;
        echo ‘</noscript>’; exit;
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *