Reply to Re: Reading from file

Your name:

Reply:


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

"Jim Michaels" <jmichae3@nospam.yahoo.com> wrote in message
news:psmdnSplZbmNf3PeRVn-pw@comcast.com...
>
> "Dalibor" <dalibor_gv@lycos.com> wrote in message
> news:61ryd700yi6d.1cs9umun3jv7f.dlg@40tude.net...
>> On Fri, 3 Feb 2006 23:52:34 +0100, 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?
>>
>> This worked:
>> <textarea>
>> <?php
>> $filename = "../msd/news.txt";
>> $handle = fopen ($filename, "r");
>> $content = fread ($handle, filesize($filename));
>> fclose($handle);
>> echo ($content);
>> ?>
>
> that could have all been done with readfile(). another cool function is
> file_get_contents() - all of them I think work with URLs also.


I forgot one thing. in a textarea, using
echo htmlentities(file_get_contents("filepath"))
is probably a good idea, if you intend to display the content on a web page
or sending HTML email, which is often the case. if you are sending plain
text email, readfile() should be just fine.

>
>> </textarea>
>>
>> Thanks everyone for helping!
>> --
>> .:Dalibor:.
>
>

[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

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