fgetss and strip_tags

fgetss and strip_tags

fgetss function
This function used read a line from a file with out HTML and PHP tags.
for parsing HTML files, we use fgetss rather fgets function .
we can do the same function by the combination of fget and strip_tags function

Syntax:
getss(fp,length);

The following two examples gives the same result.

example : 1
//Using fgetss
<?php
$fp=fopen(’sample.html’,'r’);
while(!feof($fp))
{
echo $str=fgetss($fp,4096);
}
?>

example : 2
//Using strip_tags
<?php
$fp=fopen(’sample.html’,'r’);
while(!feof($fp))
{
$str=fgets($fp);
$str=strip_tags($str);
echo $str;
}
?>

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.