Re: fopen >> custom 404 issue

From: Date: Thu, 11 Dec 2003 01:38:35 +0000
Subject: Re: fopen >> custom 404 issue
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-172419@lists.php.net to get a copy of this message
Mike D wrote:
I am trying to read in a particular page to a variable. How do you handle if the page is a 404 and then redirects to a custom error page? Am I supposed to use fsockopen and read headers or ?? Ideally I need to pull the end-result page to search for a string in it. Here's the code $handle = fopen("http://www.amazon.com/exec/obidos/ISBN=12345678", "rb"); $contents = ""; do {
     $data = fread($handle, 8192);
     if (strlen($data)==0)
         break;
     $contents .= $data;
} while(true); fclose ($handle); Thanks guys .................................... Mike Dunlop AWN, Inc. // www.awn.com [ e ] webmaster@awn.com [ p ] 323.606.4237
You can use PEAR's HTTP_Request, which will do redirects for you (and lots of other stuff ;-). http://pear.php.net/package/HTTP_Request -- paperCrane <Justin Patrin>

« previous php.general (#172419) next »