PHP » I/O » fgetss()

Syntax:
string fgetss(int file, int length [, string exempt_tags])
file
File handle of the file to read a line from.
length
Maximum length for the line. This is not optional in fgetss().
exempt_tags
A string specifying tags that should not be removed.

Reads a line from a file and strips tags.

The only difference between fgetss() and fgets() is that fgetss() also strips out any html or PHP tags, if present, before returning the data.

It returns a line from the file, up to and including the next new line character. The optional length parameter can be used to set a maximum length on the returned result. The default value for maximum length is 1024. If the call fails, FALSE is returned.

Examples

Code:
<?php

$filename = "test.txt";

// open a file for reading and writing
$logfile = fopen($filename, "w+");
// write a line with html in it
fputs($logfile, "<b>Hello world</b>");
// move back to the beginning of the file and read a line
fseek($logfile, 0);
$line = fgetss($logfile, 1024);
print "First line of $filename is: $line";

?>
Output:
First line of test.txt is: Hello world
Explanation:

This example shows that fgetss() removes html tags from the text it reads.

See Also: