脚本PHP中出错:file_get_contents():第76行/www/public_html/simple_html_dom.PHP中的文件名不能为空

脚本PHP中出错:file_get_contents():第76行/www/public_html/simple_html_dom.PHP中的文件名不能为空,php,csv,Php,Csv,我有这个剧本: <?php require('simple_html_dom.php'); error_reporting(E_ALL); $file = fopen("plikk.txt", "r") or die("Error"); $i=0; $data = array(); while(!feof($file)){ $linia=fgets($file); $html = file_get_html($linia); $data[$i]['opis']

我有这个剧本:

<?php

require('simple_html_dom.php');
error_reporting(E_ALL);
$file = fopen("plikk.txt", "r") or die("Error");
$i=0;
$data = array();
while(!feof($file)){
    $linia=fgets($file);
    $html = file_get_html($linia);
    $data[$i]['opis']  = $html->find(".editor-content",0)->innertext;
    $data[$i]['foto']  = $html->find("img",13)->src;
}

fclose($file);

$filename = 'users.csv';
$FileHandle = fopen($filename, 'w+') or die("can't open file");

foreach($data as $line){

    fputcsv($FileHandle, $line, ';', '"');

}
fclose($FileHandle);
?>

我解决了这个问题。在plik.txt文件的末尾,我有一个空行。现在它的所有工作

您的错误在simple_html_dom.php中,如果您发布该文件以检查
$linia
@u_mulder的值$linia,则可能会有所帮助。我有一行与plik.txt的代码。您需要确保$linea的值是一个有效的文件名,并在循环中提前跳过,否则使用continue;在plik.txt文件中,我有一个空行,我删除了这一行脚本add1 line to users.csv@Christopher我添加了simple_html_dom.php