Jump to content

Question About Fopen


vvutnkl

Recommended Posts

fopen() opens (loads into memory) a file so you can read it. fclose() closes it again, so you can reclaim that memory. Also look at file_get_contents().

Link to comment
Share on other sites

But what can i do with the files its open?Thanks :).
Read from it, or write to it. You do that with fread() and fwrite(), respectively. And you can move the position within the file (to which you'll write, or from which you'll read) with fseek().If you want to read the whole file, or write the whole file, you can use file_get_contents() or file_put_contents() respectively.
Link to comment
Share on other sites

Be aware that fopen does not return a file or its contents. It returns a reference to the file which is used by fread and other functions. So don't try using the return value of fopen as a string.file_get_contents() does return a big string containing the file's contents.If you know in advance that you want to put the file contents into an array, you might find file() a better solution.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...