nerd_energy Posted September 7, 2006 Share Posted September 7, 2006 OS - XP, PHP 4, 5 Objective: To write the contents of about.txt to the web page.I copied this from a PHP book and this is not working. The book states that the function fpassthru will print the contents. I also tried to replace this function with readfile function. With both pieces of code, there was no error; just empty webpage<?$fh = fopen("about.txt" , "r");if (!$fh){die("Failed to open file <b>about.txt</b>.");}$s = fread($fh, 256);fpassthru($s);fclose($fh);?>Here is my third try with another PHP Programmers help. We tried to dump the contents into an array using function FILE. However, the funny or not funny thing is in my editor FILE doesn't turn color to tell me it's a function.<?php$file = file($filename);?><html><body><?phpforeach($file as $row){echo $row;}?></body></html> Is it possible to write to a web page? I have tried other variations; even using echo. Thank you Link to comment https://forums.phpfreaks.com/topic/19965-printing-contents-of-a-file/ Share on other sites More sharing options...
Barand Posted September 7, 2006 Share Posted September 7, 2006 Seehttp://www.php.net/readfile Link to comment https://forums.phpfreaks.com/topic/19965-printing-contents-of-a-file/#findComment-87490 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.