Here's the part of my code I'm having trouble with:

$file = "letter.txt";
$letter = fopen($file, 'r');
echo $letter;

The problem is, all I'm getting on the page is "Resource id #5" instead of the contents of the file. Can someone please explain where I'm going wrong with this? File I/O in PHP is slightly different to other languages I've dealt with in the past.

Thanks in advance. 🙂

    You have to read in the contents after opening it with [man]fread[/man]. If you want to read everything in with one command then use [man]file_get_contents[/man].

      Write a Reply...