Actually if you have output buffering active then the easiest hassle free way to read a file into a variable is like this..
<? ob_start(); readfile($url, 10000); $file = ob_get_contents(); ob_end_clean(); echo $file; ?> Pretty cool eh? Hope that helps. -- Kevin Stone [EMAIL PROTECTED] -----Original Message----- From: Erik Price [mailto:[EMAIL PROTECTED]] Sent: Thursday, March 28, 2002 5:03 PM To: [EMAIL PROTECTED] Subject: [PHP] best way to read a file This is a really simple question that I've wondered for a while now... what is the best way to read a file? There are so many different functions for reading files that I have no idea which I should use. readfile() returns its values to standard output -- I don't want to use this, since my script needs to load the data in the file into a variable (it's a .xsl file). fgets() looks like it could work if I made an array out of each line read and then imploded them. fread() looks like the 'main' function for reading from files. fpassthru() -- I guess if you're already in the middle of a file it's a good way to finish? There are other functions for reading files, but they are less ambiguous, with purposes like reading from sockets or certain kinds of files. I'm not interested in those -- I just want to know which function I should use to simply read a file and store the file's contents in a variable (for later actions to be performed on/with this variable). Thank you. Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php