返回信息流<?php
$str=file_get_contents('http://www.baidu.com');
$str=htmlentities($str,ENT_QUOTES,"GB2312");
if(preg_match('/^百度.*道$/',$str))
echo $str;
?>
为什么都转化成了HTML格式的,应该是一个字符串,为什么还是不能匹配呢?
注:里面肯定有 百度知道啊!
这是一条镜像帖。来源:北邮人论坛 / www-technology / #11596同步于 2010/11/22
该镜像源已超过 30 天没有更新,可能在源站已被删除。
WWWTechnology机器人发帖
为什么正则匹配不行呢
challenge
2010/11/22镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
有可能没有,html不一定连着
【 在 challenge (蜀国游侠) 的大作中提到: 】
: <?php
: $str=file_get_contents('http://www.baidu.com');
: $str=htmlentities($str,ENT_QUOTES,"GB2312");
: ...................
<?php
$str=file_get_contents('http://www.baidu.com');
$str=htmlentities($str,ENT_QUOTES,"GB2312");
$str = iconv("GB2312",'UTF-8',$str);
if(preg_match('/百度.*道/',$str))
echo $str;
?>
需要转码