Quantcast
Channel: PHP XML disable feed if offline - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by Pekka for PHP XML disable feed if offline

$
0
0

You can use file_get_contents() and define the timeout using a stream context as explained here:Does file_get_contents() have a timeout setting?

Modified code from the answer there:

<?php$ctx=stream_context_create(array('http'=>    array('timeout' => 5 // 5 seconds    )));echo file_get_contents('http://example.com/',false,$ctx);?>

Viewing all articles
Browse latest Browse all 2

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>