Reply to Re: fopen( )

Your name:

Reply:


Posted by Kim Andrι Akerψ on 01/18/07 22:54

rfhurley wrote:

> I used this script (even tried a cut 'n' paste):
>
> // open file
> $file = fopen("welcome.txt", "r");
>
> // fetch contents of file (using filesize() to fetch the entire file
> contents
> $contents = fread($file, filesize($file));
>
> // close file, since we don't need to read it further in this session
> fclose($file);
>
> // output contents
> echo $contents;
>
>
> this didn't work. And I tried (again, I tried it a second time,
> cutting & pasting from your example):
>
> echo file_read_contents("welcome.txt");
>
>
> the "readfile()" example worked, although it ran all the lines into
> one line. But finally I found the "fgets()" function (using the
> "feof()" function to read line-by-line), and that printed out the
> text file the way I wrote it. Is there some version-related caveat to
> the "contents" functions that may affect whether they work or not
> over certain servers?
> Any 411 on that would be helpful.
>
> Thanks again!

If you're outputting this to a HTML page, you might want to do this:

echo nl2br(file_read_contents("welcome.txt"));

--
Kim AndrΓ© AkerΓΈ
- kimandre@NOSPAMbetadome.com
(remove NOSPAM to contact me directly)

[Back to original message]


УдалСнная Ρ€Π°Π±ΠΎΡ‚Π° для программистов  •  Как Π·Π°Ρ€Π°Π±ΠΎΡ‚Π°Ρ‚ΡŒ Π½Π° Google AdSense  •  England, UK  •  ΡΡ‚Π°Ρ‚ΡŒΠΈ Π½Π° английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Π‘Π°ΠΉΡ‚ ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ Π² Π‘Ρ‚ΡƒΠ΄ΠΈΠΈ Π’Π°Π»Π΅Π½Ρ‚ΠΈΠ½Π° ΠŸΠ΅Ρ‚Ρ€ΡƒΡ‡Π΅ΠΊΠ°
ΠΈΠ·Π³ΠΎΡ‚ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ ΠΈ ΠΏΠΎΠ΄Π΄Π΅Ρ€ΠΆΠΊΠ° Π²Π΅Π±-сайтов, Ρ€Π°Π·Ρ€Π°Π±ΠΎΡ‚ΠΊΠ° ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ½ΠΎΠ³ΠΎ обСспСчСния, поисковая оптимизация