Reply to Re: Reading from file

Your name:

Reply:


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

"Gordon Burditt" <gordonb.p8p96@burditt.org> wrote in message
news:11u7q6h585bvi34@corp.supernews.com...
> >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.
>
> If you output the content of a file in the middle of a bunch
> of HTML, it will be interpreted as HTML.
>
>>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?
>
> I suggest something like:
>
> echo (htmlentities($content));

you could try
echo nl2br(htmlentities($content));

which gives me
<?php echo nl2br(htmlentities("\"\n\"")); ?>
&quot;<br />
&quot;

(note that the newlines are still in there)
the 5.0 manual states that it uses xhtml's <br />. someone else stated it
didn't (maybe they were using an earlier version?).

>
> Although I don't think that will deal with newlines being interpreted
> as going to a new line, vs. HTML ignoring line breaks.
>
> Gordon L. Burditt

[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

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