Re: getting HTML header from URL [solved]

From: Date: Sat, 02 Nov 2002 02:44:06 +0000
Subject: Re: getting HTML header from URL [solved]
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-122490@lists.php.net to get a copy of this message
Jule Slootbeek wrote: > oops didn't catch two little bugs > > Jule > > function getTitle($url) > { > $file = @fopen($url, 'r'); > > if(!$file) { > $rline = "Error, contact webmaster"; > } else { > while (!feof ($file)) { > $line = fgets($file); > if (substr_count(strtoupper("$line"), "<TITLE>") >= 1) { > $rline = strip_tags("$line"); > //return $rline; > //fclose($file); > break; > } > } > return $rline; > } > fclose($file); > } 1) What if this line looks like: <html><head><title>foo</title></head><body>bar</body></html> Wont' $rline == "foobar" ? 2) Can't you use a socket and read until the first <TITLE>start saving until the </TITLE> and close the socket? -davidu

« previous php.general (#122490) next »