您好,欢迎访问一九零五行业门户网

PHP的一个语法有关问题

php的一个语法问题
php code$contents = file_get_contents($url); if((preg_match_all('/()/ius', $contents, $match))){$contents = $match[1][0];} else{ (preg_match_all('/()/ius',$contents,$match)) [color=#ff0000]$contents = $match[1][0];[/color]}
红色那行报错:
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……
其它类似信息

推荐信息