0

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 />";
    }
Dylan
  • 31
  • 4

1 Answers1

0
$filelen = @readfile($file);
if ($filelen===FALSE) {
    echo "{$file} not found <br /><br />";
}
Francis Avila
  • 31,233
  • 6
  • 58
  • 96
  • Thanks for your suggestions everyone, but i'm afraid neither ob_flush(), flush() or readfile() solved my issue. I've put a kludge in for the moment. given that my whole solution is one giant kludge i don't feel too bad about a little one... – Dylan May 11 '12 at 13:32