一段PHP代码问题
- PHP code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->$url = "http://localhost/index.php/"."$string1"; $contents = file_get_contents($url);print_r($contents);
- PHP code
<!---ecms Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--> $url = "http://localhost/index.php/"."$string1"; $contents = file_get_contents($url);//print_r($contents); if((preg_match_all('/(<h1>)/iUs', $contents, $match))){ $contents = $match[1][0]; }print_r($contents);
为什么这2段代码打印出的结果是一样的啊,这个网页是
…
结构的啊,其他类似的能成功截取,就是这个网页打印出的结果和没截取是一样的。。。
——解决方案——————–
给出你的页面内容才行呀,这样子你让人怎么猜? 有问题的肯定就是在正则咯
——解决方案——————–
第二段正则的地方输出看下
- PHP code
if((preg_match_all('/()/iUs', $contents, $match))){ echo '333'; //测试下是否正则匹配到 $contents = $match[1][0]; var_dump($contents); //打印输出看下 }
------解决方案--------------------
网页是...
结构。而 preg_match_all('/(
)/iUs 等于是匹配全部结构。本@文来源[email protected]搞@^&代*@码网(
搞代gaodaima码
又 $contents = $match[1][0]; //如果页面仅有一个...
结构。
那么。跟file_get_contents()得出的结果不是一样。是什么?
------解决方案--------------------
正则表达式有错误,改成:
preg_match_all('/.*<\/table>/sU', $contents, $match)
------解决方案--------------------
preg_match('//is',$str,$m);
echo $m[0];
------解决方案--------------------
'">3,3'-二氯联苯胺你入库的数据没有做转义处理,所以出错mediumtext类型最大可存放 16M 字符,应该足够了
------解决方案--------------------
$content=mysql_real_escape_string($contents[0]);
$SQL="INSERT INTO pagecontents (old_title,old_text) VALUES('{$string}','{$content}')";