PHP | SplFileObject fgets() Function Last Updated : 28 Apr, 2023 Comments Improve Suggest changes Like Article Like Report 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 containing the next line from the file return FALSE otherwise. Below Programs illustrate the SplFileObject::fgets() function in PHP. Program 1: php <?php // Creating SplFile Object $gfg = new SplFileObject("gfg.txt"); while (!$gfg->eof()) { echo $gfg->fgets(); } ?> Output: GeeksfoGeeks A Computer Science Portal For Geeks. Program 2: php <?php // Creating SplFile Object $gfg = new SplFileObject(__FILE__); while (!$gfg->eof()) { echo $gfg->fgets(); } ?> Output:<?php // Creating SplFile Object $gfg = new SplFileObject(__FILE__); while (!$gfg->eof()) { echo $gfg->fgets(); } ?> Reference: http://php.net/manual/en/splfileobject.fgets.php Comment More infoAdvertise with us Next Article PHP | SplFileObject fgets() Function R R_Raj Follow Improve Article Tags : PHP PHP-function PHP-SplFileInfo Similar Reads 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 whic 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 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 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 PHP | SplFileObject ftell() Function The SplFileObject::ftell() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to return the position of the file pointer which specifies the current offset in the file. Syntax: int SplFileObject::ftell( void ) Parameters: This function does not accept any parameters. 1 min read PHP SplFileObject fseek() Function The SplFileObject::fseek() function is an inbuilt function of Standard PHP Library (SPL) in PHP that allows you to move the file pointer to a specified position within a file opened using SplFileObject. The file pointer is the position where the next read or write operation will occur. This function 2 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 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 fflush() Function The SplFileObject::fflush() function is an inbuilt function in the Standard PHP Library (SPL) in PHP that is used to flush the output buffer of the file. Syntax: public SplFileObject::fflush():boolParameter: This function does not accept any parameters. Return Value: The SplFileObject::fflush() func 2 min read PHP | SplFileObject current( ) Function The SplFileObject::current() function is an inbuilt function of Standard PHP Library (SPL) in PHP which is used to get current line of file. Syntax: string SplFileObject::current( void ) Parameters: This function does not accept any parameter. Return values: Returns current line of the file. Below P 2 min read Like