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() The same, but fgetss tries to remove any HTML and PHP tags from the text it reads.
Syntax
fgetss(file,length,tags)
Parameters | 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 removed. |
Description
You can use 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 output source code is:
<p><b>This is a paragraph.</b></p>