Sign in to follow this  

[web] PHP - reading the file

Recommended Posts

I used to use PHP, but stopped for multiple reasons. Now I am re-teaching it to myself. Right now to test my memory I pulled out an old project from the "to program" area (everything, but the code it done). The program is a P2P chat client to be used to communicate with my game development team. The one part that won't work is reading from the files. I don't quite remember how to do this. The code that I used is: while (!feof($f)) { $x=fgetc($f); $uo = $uo + $x; } All that I am trying to do is get the content of the file stored as a variable($uo).

Share this post

Link to post
Share on other sites
Or just:

$file = file("fileURL");

foreach ($file as $line) {
$uo = $uo.$line;

Edit: But reading that above URL, file_get_contents() is easier still.

$uo = file_get_contents("fileURL");

Share this post

Link to post
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

Sign in to follow this