Reply to Re: Reading from file

Your name:

Reply:


Posted by Jim Michaels on 02/12/06 09:19

"NC" <nc@iname.com> wrote in message
news:1139025405.407267.10860@g43g2000cwa.googlegroups.com...
> Dalibor wrote:
>>
>> I have following code for putting contenst of a file into a web page:
>> <?php
>> $filename = "../msd/news.txt";
>> $handle = fopen ($filename, "r");
>> $content = fread ($handle, filesize($filename));
>> fclose($handle);
>> echo ($content);
>> ?>
>> But in file news.txt I have formating that is not showing, but
>> interpreting.
>> For example, in that file there is:
>> <a href="link.php">link</a>
>> End result is hyperlink.
>>
>> Can you tell me what I did wrong?
>
> You forgot to output <pre> tags. Also, you should know that there is a
> much faster and easier way of outputting a text file; you should use
> readfile(). So your code should look like this:
>
> $filename = "../msd/news.txt";
> echo "<pre>\r\n";

even if you use pre, you still must use htmlentities() to produce valid HTML
(like on > and < and "). checked it out on 2 validators. doesn't make a
diff whether it's code or pre.

> readfile($filename);
> echo "</pre>\r\n";
>
> Cheers,
> NC
>

[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

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация