PHP fgetss() Function
Definition and Usage
The fgetss() function reads a line from the opened file and filters out HTML and PHP tags.
With fgets() Same, but fgetss tries to remove any HTML and PHP tags from the text it reads.
Syntax
fgetss(file,length,tags)
Parameter | Description |
---|---|
file | Required. Specifies the file to be read. |
length | Optional. Specifies the number of bytes to read. The default is 1024 bytes. This parameter was required before PHP 5. |
tags | Optional. Specifies tags that will not be deleted. |
Description
Can be used with an optional third parameter tags Specify which tags are not removed.
If it fails, it returns false.
Example
Example 1
<?php $file = fopen("test.htm","r"); echo fgetss($file); fclose($file); ?>
Output similar to:
This is a paragraph.
Example 2
<?php $file = fopen("test.htm","r"); echo fgetss($file,1024,"<p>,<b>"); fclose($file); ?>
Output similar to:
This is a paragraph.
The source code output is:
<p><b>This is a paragraph.</b></p>