First, recommended method Curl gets
$c = Curl_init ();
$url = ' www.php.net ';
curl_setopt ($c, Curlopt_url, $url);
curl_setopt ($c, Curlopt_returntransfer, 1);
$data = curl_exec ($c);
Curl_close ($c);
$pos = Strpos ($data, ' utf-8 ');
if ($pos ===false) {$data = Iconv ("GBK", "Utf-8", $data);}
Preg_match ("/(. *) <\/title>/i ", $data, $title); <br>echo $title [1];<br>?></p><p> Second, use the file () function </P><P><?php<BR> $lines _array = file (' http://www.php.net/');<br> $lines _string = implode ( ", $lines _array); <BR> $pos = Strpos ($lines _string, ' utf-8 '); <br>if ($pos ===false) {$lines _string = iconv ("GBK", "Utf-8", $ lines_string);} <br>eregi ("<title> (. *)", $lines _string, $title);
echo $title [1];
?>
Third, the use of file_get_contents
$content =file_get_contents ("http://www.php.net/");
$pos = Strpos ($content, ' utf-8 ');
if ($pos ===false) {$content = Iconv ("GBK", "Utf-8", $content);}
$postb =strpos ($content, '') +7;<br> $poste =strpos ($content, '');
$length = $poste-$postb;
Echo substr ($content, $POSTB, $length);
?>