PHP syntax: PHPcode $ contents = file_get_contents ($ url); if (preg_match_all ('/(& lt; h1. * & lt; \/table & gt ;) /iUs ', $ contents PHP syntax
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]}
The Red Line reports the following error:
Parse error: syntax error, unexpected T_VARIABLE in
I want to capture part of the webpage information. There are two types of frameworks on the webpage, and the regular expressions are the two types. so I want to make a judgment, if it is not the first framework, the second regex is used to capture webpage information.
However, if else syntax is used to report an error.
Write the php code of the two regular expressions separately. The two are correct. if they are combined, they will be wrong. I don't know much about PHP. please help me.
------ Solution --------------------
(Preg_match_all ('/()/iUs', $ contents, $ match) <= The Row Terminator ";" is missing.
------ Solution --------------------
Put the operation in the loop
$ 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];
}
}
Discussion
There is another problem:
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 ......