fgets() expects parameter 1 to be resource, null given
laravel 5.2
why is null file on fgets($this->file))? because it's first time i'm used laravel 5.2
fgets change with file_get_contents but it still didn't work
class FileDataSource implements IDataSource {
protected $filename;
protected $file;
/**
* Constructor
*
* @param string $filename
* @return FileDataSource
*/
public function __construct($filename) {
$this->filename = $filename;
$this->open();
return $this;
}
/**
* Destructor
*/
public function __destruct() {
$this->close();
}
/**
* Opening file
*/
public function open() {
if (is_file($this->filename))
$this->file = fopen($this->filename, 'r');
}
/**
* Closing file
*/
public function close() {
fclose($this->file);
}
/**
* Reading next document from file
*
* @return string | boolean
*/
public function getNextDocument() {
// if it's possible to read from file, remove new line character
return (($line = fgets($this->file)) !== false)
? trim(preg_replace('/\s\s+/', ' ', $line))
: false;
}
from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2Zbt0LU
via IFTTT
Aucun commentaire:
Enregistrer un commentaire