0
$fp = fsockopen("www.example.com", 8000, $errno, $errstr, 1); //last param is timeout in seconds
if (!$fp) {
    header('Location: http://www.anothersite.com/some_message');
} else {
    fclose($fp); // radio OK
}

The code is not working and do not redirect.

  • There are many ways to make a redirect in PHP, HTML header or JavaScript. Please check [this answer](http://stackoverflow.com/a/768472) for instance. – roberto06 Nov 03 '16 at 15:56
  • Yes i saw these answers but they are not for a radio stream... – Patrick Troust Nov 03 '16 at 16:01
  • I don't understand how the fact that you're trying to open a radio stream is relevant. Just use `if (!$fp) { header('Location: '.$newURL); }`. Unless there's something obvious I'm missing... – roberto06 Nov 03 '16 at 16:05
  • tryed but not working :( – Patrick Troust Nov 03 '16 at 16:16
  • Normally you can not do a header redirect after you've sent output. So instead of the `echo error` line, do your redirect there, and on the landing page, show the viewer the stream is unavailable message. PS if you have changed your code, please edit your question to match what you currently have – Duane Lortie Nov 03 '16 at 17:57
  • I have changed my code for understanding what i try to do Thanks Duane – Patrick Troust Nov 03 '16 at 19:38

1 Answers1

0
ob_start();
//something
ob_end_clean(); //erase output
header('Location: ');