Easy Tutorial
❮ Func Directory Opendir Func Date Get Last Errors ❯

PHP fgetss() Function



Definition and Usage

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

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

If it fails, the function returns FALSE.

Syntax

Parameter Description
file Required. Specifies the file to check.
length Optional. Specifies the number of bytes to read. The default is 1024 bytes. Note: This parameter was required in versions of PHP prior to 5.
tags Optional. Specifies which tags should not be removed.

Examples

Example 1

test.html 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:

The output source code is:

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

❮ Func Directory Opendir Func Date Get Last Errors ❯