...

View Full Version : fread strip html tags



Eran
10-08-2009, 08:10 PM
i'm reading a text file and it strips html tags like fgetss.
why does it happen?

I tried file_get_contents and fread but not reading the tags.

e.g
data.txt


today is a <new> green day

file.php


$file='data.txt';
$fh = fopen($file, 'r');
$contents = fread($fh, filesize($file));
fclose($fh);
echo $contents;
//outputs: "today is a green day"

yes, it cuts the "<new> " with the space :|

how can i read the html tags?

seco
10-08-2009, 08:21 PM
try this

echo htmlentities($contents);
or look into php html functions

AaronC
10-08-2009, 08:25 PM
$file='data.txt';
$fh = fopen($file, 'r');
$contents = fread($fh, filesize($file));
fclose($fh);
echo htmlspecialchars($contents);


that may work, i'm not a great coder so there is probably a better way! (UPDATED)

Eran
10-08-2009, 08:37 PM
ohh yes you right! silly me
i was confused because i saw its ok on the txt file...

thanks

AaronC
10-08-2009, 08:39 PM
No worries if you mean me, glad i could help.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum