我不确定为什么以下代码在 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 parser api) 来解析 html 页面。当我在 PHP 5.2 上运行此代码时,它会在“//error here”处显示一条错误消息,说明“在第 67 行解析错误”
谢谢