Reply to Re: Reading from file

Your name:

Reply:


Posted by jukka on 02/04/06 20:54

Johannes Wienke wrote:
> Hello,
>
> Dalibor schrieb:
>> 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.
>
> I think the problem has nothing to do with your PHP-Code. Can you post a
> link with the result of your code an the textfile?
>
> To shorten your code you can also use file_get_contents.
> http://de.php.net/filegetcontents
>
> Johannes

the problem is you're echoing the contents so it gets processed like
html. one thing you could do is put:
header("Content-type: text/plain");
echo $content;
But that's only if you have nothing after the contents. You could also
convert the < and > to &lt; and &gt; and I'm sure there is some other
simple solution but nothing comes to mind right now. :)

[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

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