Re: Test links?

From: Date: Sat, 30 Nov 2002 18:39:50 +0000
Subject: Re: Test links?
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-126555@lists.php.net to get a copy of this message
On Sunday 01 December 2002 02:06, Rob Packer wrote: > Okay, I'm confused... file, fopen, and fsockopen seem to say not found on > alot valid URLs... does this look to be correct usage? > $url = $row[0]; // just get the url from the db > $fp = implode ('', file ($url)); > if (!$fp) {echo "<font color=red><b>Unable to access > file</b></font>"; } > else { fclose($fp); echo "The link is working!"; } > > It seems I always get this warning... > > Warning: Supplied argument is not a valid File-Handle resource in > /web/home/nrc.net/www/robert/links4.php on line 11 Which is line 11? In the above, if link was valid and returned something then $fp would be a string containing the HTML source of the $url. If the link was invalid (I'm not sure what exactly PHP would regard as an invalid link) then PHP would output a warning/error message (make sure you have error reporting set to an appropriately high level). file() implicitly opens and closes the file for you so no need for fclose(). -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * /* The rhino is a homely beast, For human eyes he's not a feast. Farewell, farewell, you old rhinoceros, I'll stare at something less prepoceros. -- Ogden Nash */

« previous php.general (#126555) next »