PHP | SplFileObject fgetss() Function Last Updated : 11 Jul, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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::fgetss() function in PHP.Program 1: php <?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 <?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: https://www.php.net/manual/en/splfileobject.fgets.php Comment More infoAdvertise with us Next Article PHP | SplFileObject fstat() Function R R_Raj Follow Improve Article Tags : PHP PHP-function PHP-SplFileInfo Similar Reads PHP | SplFileObject fgets() Function The SplFileObject::fgets() function is an inbuilt function of the Standard PHP Library (SPL) in PHP which is used to get a line from the file. Syntax: string SplFileObject::fgets( void ) Parameters: This function does not accept any parameter. Return values: This function returns a string contain 1 min read PHP | SplFileObject fgetc() Function The SplFileObject::fgetc() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get character from file. Syntax: string SplFileObject::fgetc( void ) Parameters: This function does not accept any parameter. Return values: Returns single character read from the file or 1 min read PHP | SplFileObject fputcsv() Function The SplFileObject fputcsv() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used write a field array as a CSV line. Syntax: string SplFileObject::fputcsv() Parameters: This function accept four parameters one is mandatory and three are optional. $fields: Specifies the a 1 min read PHP | SplFileObject fstat() Function The SplFileObject::fstat() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to give the information of the file. Syntax: array SplFileObject::fstat( void ) Parameters: This function does not accept any parameter. Return values: This function returns an array which c 1 min read PHP | SplFileObject eof() Function The SplFileObject::eof() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used reached end of file. Syntax: string SplFileObject::eof( void ) Parameters: This function does not accept any parameter. Return values: Returns TRUE on Success. Below Programs illustrate the Sp 1 min read PHP | SplFileObject fread() Function The SplFileObject::fread() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to reads the given number of bytes from the file. Syntax: string SplFileObject::fread( $length ) Parameters: This function accepts single parameter $length which is used to specify the lengt 1 min read Like