Reputation: 31
I have a script which opens a file then prints its contents (for a long, silly reason that doesn't bear explaining). The issue i have is, it often refuses to work, unless i echo some other text first. The code below doesn't work, but if i put
echo "a";
or echo " ";
first, it does. Even more strange, echo " ";
is insufficient.
What does echoing some text do?
//...a bunch of code to get the file name
if(file_exists($file))
{
$fp=fopen($file, "r");
$temp = fread( $fp, filesize($file));
echo $temp;
}
else
{
echo $file." not found<br /><br />";
}
Upvotes: 0
Views: 351
Reputation: 31641
$filelen = @readfile($file);
if ($filelen===FALSE) {
echo "{$file} not found <br /><br />";
}
Upvotes: 0