vvutnkl Posted October 11, 2009 Share Posted October 11, 2009 Hello.I'm new here, I'm coming from Israel, And i dont know english very well.I have a question about "fopen", "fclose", etc.What does it do?Thank you, Orel. Link to comment Share on other sites More sharing options...
Synook Posted October 11, 2009 Share Posted October 11, 2009 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 More sharing options...
vvutnkl Posted October 11, 2009 Author Share Posted October 11, 2009 But what can i do with the files its open?Thanks . Link to comment Share on other sites More sharing options...
boen_robot Posted October 11, 2009 Share Posted October 11, 2009 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 More sharing options...
jeffman Posted October 11, 2009 Share Posted October 11, 2009 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.