Pain Posted June 21, 2012 Share Posted June 21, 2012 Hi. I ran into this function called file_get_contents() However it is not clear to me when is the best moment to use it. I mean if you want to open a text file you can always use fopen. Quote Link to comment https://forums.phpfreaks.com/topic/264578-file_get_contents-usage/ Share on other sites More sharing options...
Barand Posted June 21, 2012 Share Posted June 21, 2012 use it when you want to read the whole content of the file into a variable. Have you considered reading the manual? Quote Link to comment https://forums.phpfreaks.com/topic/264578-file_get_contents-usage/#findComment-1355926 Share on other sites More sharing options...
xyph Posted June 21, 2012 Share Posted June 21, 2012 fopen is good when you want to access a file, in parts. file_get_contents is like using fopen, fget, fclose in a single statement. It's easier. When dealing with huge files, it's generally a good ideal to read it in parts, rather than all at once. This is when you want to use fopen. Pretty much what Barand said. Quote Link to comment https://forums.phpfreaks.com/topic/264578-file_get_contents-usage/#findComment-1355939 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.