what is the meaning of this Resource id #4

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
tinoda
Forum Commoner
Posts: 33
Joined: Mon Dec 29, 2008 3:32 am

what is the meaning of this Resource id #4

Post by tinoda »

i keep getting the: Resource id #4 as my output each time i try to run this script. where am i going wrong.

<?PHP

$file_contents = fopen("testFile.txt", "r");
print $file_contents;
fclose($file_contents);

?>
User avatar
VladSun
DevNet Master
Posts: 4313
Joined: Wed Jun 27, 2007 9:44 am
Location: Sofia, Bulgaria

Re: what is the meaning of this Resource id #4

Post by VladSun »

tinoda wrote:i keep getting the: Resource id #4 as my output each time i try to run this script. where am i going wrong.

<?PHP

$file_contents = fopen("testFile.txt", "r");
print $file_contents;
fclose($file_contents);

?>
It's a file handle. If you need the file contents use filegetcontents instead of fopen OR you should read the file line by line -fgets(), or block by block - fread() after opening it.
There are 10 types of people in this world, those who understand binary and those who don't
tinoda
Forum Commoner
Posts: 33
Joined: Mon Dec 29, 2008 3:32 am

Re: what is the meaning of this Resource id #4

Post by tinoda »

It's a file handle. If you need the file contents use filegetcontents instead of fopen OR you should read the file line by line -fgets(), or block by block - fread() after opening it.
you know what Vladsun you are just the person of the day today. u really brightened my day, vielen danke, thank u very much - it worked
Post Reply