Re: Test if URL is alive before including a remote JS

From: Date: Tue, 02 Jul 2002 20:35:11 +0000
Subject: Re: Test if URL is alive before including a remote JS
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-105022@lists.php.net to get a copy of this message
It's good programming ediquite but not required. All fclose does is destroy the handle which will be lost when the script terminates.. same difference. -Kevin ----- Original Message ----- From: "Verdon Vaillancourt" <verdon@mac.com> To: "Kevin Stone" <kevin@helpelf.com>; <php-general@lists.php.net> Sent: Tuesday, July 02, 2002 1:55 PM Subject: Re: [PHP] Test if URL is alive before including a remote JS > Thanks Kevin, > > Do I need to include 'fclose ($fp);' in there somewhere in this case? > > > On 7/2/02 3:41 PM, "Kevin Stone" <kevin@helpelf.com> wrote: > > > Or just fopen() would work fine. > > -Kevin > > > > ----- Original Message ----- > >> Hi :) > >> > >> Given I have some content embedded on my page by calling a remote JS and > >> occasionally the URL for the remote script is down causing my page to be > >> slow or fail, can I use the following example as a means to test and > > timeout > >> the remote server and skip the embedded JS, if the remote server isn't > >> responding properly? > >> > >> <?php > >> $fp = fsockopen ("www.theweathernetwork.com", 80, $errno, $errstr, 5); > >> if (!$fp) { > >> echo "sorry, not available"; > >> } else { > >> echo "<script language=\"JavaScript\" > >> type=\"text/javascript\"> > >> <!-- var city = \"Muskoka_ON\"; //--> > >> </script> > >> <script language=\"javascript\" > >> type=\"text/javascript\" > >> src=\"http://www.theweathernetwork.com/weatherbutton/test.js\"> > >> </script>"; > >> > >> } > >> ?> > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php >

« previous php.general (#105022) next »