Copy the code The code is as follows:
$title='this site';
$hello='jb51.net!';
$file=file_get_contents('http://www. baidu.com');
$file=iconv("gbk//IGNORE","utf-8",$file);
//echo $file;
echo strpos($file,'
Copy the code The code is as follows:
function _url($Date){
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_UR L, "$ Date");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$contents = curl_exec($ch);
curl_close($ch);
return $contents;
}
$url="http://www.jb51.net";
$contents.=_url ($url);
echo $contents; //Output content
?>
The above introduces the simple code for string PHP to read HTML and intercept strings, including string content. I hope it will be helpful to friends who are interested in PHP tutorials.