I'm using basic PHP include statements on my sites, and sometimes they call up content from a second website. Currently I use something basic like this: <?php @include("http://www.domain1.co.uk/content.php"); ?> Code (markup): However, I'd like to add some simple PHP code that will, if domain1 cannot be reached, instead call up the same file from domain2.co.uk. Any suggestions would be very welcome.
Try using fopen instead. eg $handle = fopen("http://www.example.com/", "r"); if($handle){ echo"$handle"; } else { $handle = fopen("http://www.example2.com/", "r"); echo"$handle"; } PHP: edit: you may need to set the timeout of the first url to be quite short in the php ini file
Judging by the documentation on php.net, this bit of code might work: if ((include 'http://www.domain1.com/script.php') != 'OK') { include 'http://www.domain1.co.uk/script.php'; } PHP: I haven't used remote includes in my own code though, so I can't guarantee that this will work.