Jump to content

Question About Fopen


vvutnkl
 Share

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. Edited by boen_robot
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...