PHP fgetss()Functions


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual

Definition and Usage

The fgetss() function returns a line from an open file and filters out HTML and PHP tags.

The fgetss() function stops returning a new line when it has reached the specified length or reached the end of file (EOF), whichever comes first.

Returns FALSE on failure.

Syntax

fgetss(file,length,tags)

Parameter Description
file Required. Specifies the file to check.
length Optional. Specifies the number of bytes to read. Default is 1024 bytes.

Note:This parameter is required in versions before PHP 5.

tags Optional. Specifies which tags are not stripped.


Examples

Example 1

test.html code content:

<p><b>This is a paragraph.</b></p>

PHP code:

<?php
$file = fopen("test.html","r");
echo fgetss($file);
fclose($file);
?>

The above code will output:

This is a paragraph.

Example 2

<?php
$file = fopen("test.html","r");
echo fgetss($file,1024,"<p>,<b>");
fclose($file);
?>

The above code will output:

This is a paragraph.

The source code of the above output is:

<p><b>This is a paragraph.</b></p>


PHP Filesystem 参考手册Complete PHP Filesystem Reference Manual Other Extensions