A syntax related to PHP

Source: Internet
Author: User
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 ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.