Snubby Posted October 14, 2006 Share Posted October 14, 2006 How do I read the whole contents of a file and not just one line (fgets)? When I just go...$file = fopen ("file", "r");echo $file;...It doesn't work. Link to comment Share on other sites More sharing options...
Guest eyalk7 Posted October 14, 2006 Share Posted October 14, 2006 To read a file line by line you need to use the 'fgets' function: while(!feof($file)) { echo fgets($file). "<br />"; } for more info - W3schools - PHP File Link to comment Share on other sites More sharing options...
Snubby Posted October 14, 2006 Author Share Posted October 14, 2006 oh ok, I get it now. Somehow I was under the impression that only read the same line over and over. Thanks for the quick reply! Link to comment Share on other sites More sharing options...
justsomeguy Posted October 14, 2006 Share Posted October 14, 2006 You can also use this to get the entire file at once:http://www.php.net/manual/en/function.file-get-contents.php Link to comment Share on other sites More sharing options...
jhecht Posted October 15, 2006 Share Posted October 15, 2006 fread() would work as well.... Link to comment Share on other sites More sharing options...
Akula_dude Posted October 15, 2006 Share Posted October 15, 2006 As would file_get_contents() Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now