+ 1

Why PHP outputs "Resource id #3 " ??

<?PHP $myfile=fopen("solo.txt","w"); $txt="Shahabuddin\n"; fwrite($myfile,$txt); echo $myfile; ?> //Output: Resource id #3

10th Apr 2018, 5:50 AM
Md Shahabuddin Hossain
Md Shahabuddin Hossain - avatar
2 ответов
+ 3
Because you get a resource pointer in return and not the actual content by using echo $myfile; Read the file and print its contents instead: <?php $myfile=fopen("solo.txt","w"); $txt="Shahabuddin\n"; fwrite($myfile,$txt); $read = file('solo.txt'); foreach ($read as $line) { echo $line .""; } ?>
10th Apr 2018, 6:34 AM
Dev
Dev - avatar
0
Thank you mr dev. Let me try again :)
10th Apr 2018, 6:45 AM
Md Shahabuddin Hossain
Md Shahabuddin Hossain - avatar