PHP | SplFileObject fgetss() Function
The SplFileObject::fgetss() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get line from file and strip HTML tags.
Syntax:
string SplFileObject::fgetss( $tags)
Parameters: This function accept only one parameter $tags an optional parameter to specify tags which should not be stripped.
Return values: This function returns the next line of the file with HTML and PHP code stripped return FALSE otherwise.
Below Programs illustrate the SplFileObject::fgets() function in PHP.
Program 1:
<?php $gfg = <<<EOD <html><body> <h1>Welcome To GeeksforGeeks!</h1> </body></html> Text out of the HTML block. EOD; file_put_contents("gfg.txt", $gfg); $file = new SplFileObject("gfg.txt"); while (!$file->eof()) { echo $file->fgetss(); } ?> |
Output:
Welcome To GeeksforGeeks! Text out of the HTML block.
Program 2:
<?php $gfg = <<<EOD <html><body> <h1>Welcome To GeeksforGeeks!</p> </body></html> Text out of the HTML block. EOD; file_put_contents(__FILE__, $gfg); $file = new SplFileObject(__FILE__); while (!$file->eof()) { echo $file->fgetss(); } ?> |
Output:
Welcome To GeeksforGeeks! Text out of the HTML block.
Reference: http://php.net/manual/en/splfileobject.fgets.php
Recommended Posts:
- PHP | fgetss( ) Function
- PHP | SplFileObject eof() Function
- PHP | SplFileObject fputcsv() Function
- PHP | SplFileObject flock() Function
- PHP | SplFileObject fgets() Function
- PHP | SplFileObject setMaxLineLen() Function
- PHP | SplFileObject fread() Function
- PHP | SplFileObject ftruncate() Function
- PHP | SplFileObject getMaxLineLen() Function
- PHP | SplFileObject ftell() Function
- PHP | SplFileObject fstat() Function
- PHP | SplFileObject fgetc() Function
- PHP | SplFileObject seek() Function
- PHP | SplFileObject rewind() Function
- PHP | SplFileObject fwrite() 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 contribute@geeksforgeeks.org. 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.



