Skip to content

Instantly share code, notes, and snippets.

@bytefade
Created April 1, 2015 13:05
Show Gist options
  • Save bytefade/4cce59332da22c96e21d to your computer and use it in GitHub Desktop.
Save bytefade/4cce59332da22c96e21d to your computer and use it in GitHub Desktop.
Função para redirecionamento: Que funciona em todos situações, mesmo se cabeçalhos já estão enviados ou mesmo javascript está desativado.
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;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment