无法在php中找到错误,解析错误:语法错误,意外' preg_match' (T_STRING)

时间:2015-03-25 03:08:02

标签: php

php新手。我在确定代码中的错误时遇到了问题。我一直收到这个错误

  

解析错误:语法错误,意外' preg_match' (T_STRING)in   /Applications/MAMP/htdocs/blackiris/blackiris/syriaexhibition/syriaexhibition.php   第16行

header('content-type: text/plain');
$contents = file_get_contents('https://www.youtube.com/results?search_sort=video_date_uploaded&search_query=syria');
$contents = preg_replace('/\s(1,)/', ' ', $contents);

print $contents . "\n";
// if ($contents === false)
//  print 'False';
// print_r($contents);
$records = $preg_split('/<h3 class="yt/', $contents);

for ($ix = 1; $ix < count($records); $ix++)  (
$tmp = $records[$ix]

preg_match('/href="(.*?)"/', $tmp, $match_url);

print_r($match_url);

exit();
)

1 个答案:

答案 0 :(得分:1)

$tmp = $records[$ix]后需要分号,而foreach中的()应为{}

for ($ix = 1; $ix < count($records); $ix++)  {
  $tmp = $records[$ix];                   // ^ //
                   // ^ //
  preg_match('/href="(.*?)"/', $tmp, $match_url));

  print_r($match_url);

  exit();
}  // < //