PHP的一个语法有关问题

WBOY
풀어 주다: 2016-06-13 13:42:37
원래의
809명이 탐색했습니다.

PHP的一个语法问题

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
$contents = file_get_contents($url); 
if((preg_match_all('/(<h1.>)/iUs', $contents, $match))){
$contents = $match[1][0];
} 
else{
    (preg_match_all('/(<h1.>)/iUs',$contents,$match))
    [color=#FF0000]$contents = $match[1][0];[/color]
}

</h1.></h1.>
로그인 후 복사

红色那行报错:
Parse error: syntax error, unexpected T_VARIABLE in 

我这是要抓取网页的部分信息,网页有2种框架,正则就是这2种,所以想做个判断,不是第一种框架的正则就用第二种的正则来截取网页信息。
但是用if else语法报错。
分开写这2个正则的php代码,这2个都没错,合在一起就错了。不太了解PHP,求大家帮帮忙了。

------解决方案--------------------
(preg_match_all('/()/iUs',$contents,$match)) ------解决方案--------------------
操作放到循环里面去

$contents = '';
while($rows=mysql_fetch_array(mysql_query("select pl_title from pagelinks limit 1,10")))
{
$string=$rows['pl_title'];
$string1=urlencode($string);

$url = "http://localhost/index.php/"."$string1";
$contents = file_get_contents($url);
if((preg_match_all('/()/iUs', $contents, $match)))
{
$contents .= $match[1][0];
}
else
{
(preg_match_all('/()/iUs',$contents,$match));
$contents .= $match[1][0];
}
}

探讨

还有一个问题:
PHP code


if($rows=mysql_fetch_array(mysql_query("select pl_title from pagelinks limit 1,10"))){
$string=$rows['pl_title'];
$string1=urlencode($string);
}
echo $string;
$url = "htt……
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!