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 reaches the end of file (EOF), whichever comes first.
This function returns FALSE on failure.
fgetss(file,length,tags)
| parameter | describe |
|---|---|
| file | Required. Specifies the documents to be checked. |
| length | Optional. Specifies the number of bytes to read. The default is 1024 bytes. Note: This parameter is required in versions prior to PHP 5. |
| tags | Optional. Specify which tags are not to be removed. |
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.
<?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 output above is:
<p><b>This is a paragraph.</b></p>