Re: Handle time-outs and errors with file()

From: Date: Thu, 31 Jan 2008 01:08:33 +0000
Subject: Re: Handle time-outs and errors with file()
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-268392@lists.php.net to get a copy of this message
On Tue, January 29, 2008 9:58 am, John Papas wrote: > I'm using file() to get the contents of a remote page in my script but > I cannot find any information regarding how I could *gracefully* > handle a broken network connection or even a time-out (slow > connection). > > Is there a way? > > --- > Example: > $menu = file('http://www.remotesite.org/mypage.html'ÓO]€ > ~>^#M¾jlÖ5); Use http://php.net/set_error_handler You can change the timeout with set_ini() right before the file() call. If $menu === false, then it failed. > foreach ($menu as $line_num => $line) { > echo $line."\n"; > } > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- Some people have a "gift" link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/from/lynch Yeah, I get a buck. So?

« previous php.general (#268392) next »