You need to know that if the $length parameter of fread() is 0, it will be Faltal Error.
<?php
$filepath = "example/a/dir/file.txt";
$fp = fopen($filepath, "c+");
fseek($fp, 0);
$fileSize = fstat($fp)["size"];
if ($fileSize <= 0) {
$txt = "";
} else {
$txt = fread($fp, $fileSize);
}
echo $txt;
?>
I'm Japanese so if I took some mistakes, very sorry.
thanks!