Quick PHP file_get_contents/readfile query

Gary Stainburn gary.stainburn at ringways.co.uk
Thu Jun 22 08:17:42 UTC 2006


What is the difference between readfile and file_get_contents+echo?

Why does my code work when I use readfile but not when I use file_get_contents 
followed by echo?

By work I mean M$ Excel opens and reads the spreadsheet properly. When it 
fails, Excel shows an empty spreadsheet which to me says the XML has been 
corrupted.

<? # vim: ft=php ai et tw=0
header('content-type: text/xml');
header("Content-Disposition: attachment; filename=\"adoptions.xls\"");
$file=file_get_contents('/home/httpd/uploads/ADOPTIONS.xml');
echo $file;

#readfile('/home/httpd/uploads/ADOPTIONS.xml');
exit;
?>

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     




More information about the fedora-list mailing list