时间:2021-07-01 10:21:17 帮助过:16人阅读
$title='本站';
$hello='jb51.net!';
$file=file_get_contents('http://www.baidu.com');
$file=iconv("gbk//IGNORE","utf-8",$file);
//echo $file;
echo strpos($file,'
代码如下:
function _url($Date){
$ch = curl_init();
$timeout = 5;
curl_setopt ($ch, CURLOPT_URL, "$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.gxlcms.com";
$contents.=_url($url);
echo $contents; //输出内容
?>
以上就介绍了字符串 php读取html并截取字符串的简单代码,包括了字符串方面的内容,希望对PHP教程有兴趣的朋友有所帮助。