次のコードが PHP 5.2 でエラー メッセージを表示する理由はわかりませんが、php 5.4 では完全に機能しています。
$f_channelList = array();
$f_channelCounter = 0;
$f_channel = null;
foreach ($f_pageContent->find("div.col") as $f_channelSchedule){
$f_channel = $f_channelSchedule->find("h2.logo")[0];//error here
if(trim($f_channel->plaintext) != " " && strlen(trim($f_channel->plaintext))>0){
if($f_channelCounter == 0){
mkdir($folderName);
}
array_push($f_channelList, $f_channel->plaintext);
$f_fileName = $folderName . "/" . trim($f_channelList[$f_channelCounter]) . ".txt";
$f_programFile = fopen($f_fileName, "x");
$f_fileContent = $f_channelSchedule->find("dl")[0]->outertext;
fwrite($f_programFile, $f_fileContent);
fclose($f_programFile);
$f_channelCounter++;
}
}
また、コードで simple_html_dom.php (html パーサー API) を使用して HTML ページを解析しています。このコードを PHP 5.2 で実行すると、「//error here」に「parse error at line number 67」というエラー メッセージが表示されます。
ありがとう