The fgetss() function in PHP is an inbuilt function which is used to return a line from an open file after removing HTML and PHP tags from the respective file.
The fegtss() function stops returning at a specified length, on end of file(EOF) or on a new line, whichever comes first.
The file to be read and the number of bytes to be read are sent as parameters to the fgetss() function and it returns a string of length -1 bytes from the file pointed by the user. It returns False on failure.
fgetss(file, length, tags)
The fgetss() function in PHP accepts three parameter.
- file: It specifies the file from which characters have to be extracted.
- length: It specifies the number of bytes to be read by the fgetss() function. The default value is 1024 bytes.
- tags: It is an optional paaremeter which is used to specify tags which should not be striped.
It returns a string of length -1 bytes from the file pointed by the user after removing all the HTML and PHP tags.
Errors And Exception:
- The function is not optimised for large files since it reads a single line at a time and it may take a lot of time to completely read a long file.
- The buffer must be cleared if the fgetss() function is used multiple times.
- The fgetss() function returns Boolean False but many times it happens that it returns a non-Boolean value which evaluates to False.
Below programs illustrate the fgetss() function.
Suppose there is a file named “gfg.txt” which consists of :
This is the first line.
- PHP | SplFileObject fgetss() Function
- How to get the function name inside a function in PHP ?
- p5.js | arc() Function
- p5.js | sq() function
- p5.js | second() function
- p5.js | pow() function
- p5.js | day() function
- p5.js | max() function
- PHP | tan( ) Function
- p5.js | hue() function
- p5.js | min() function
- PHP | abs() Function
- PHP | sin( ) Function
- PHP | cos( ) Function
- PHP | Ds\Set contains() Function
- PHP | Ds\Map first() Function
- PHP Ds\Map sum() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.