Found 35163 Articles for Programming

fgets() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:50:48

362 Views

The fgets() function returns a line from a file. It returns a string of up to length - 1 bytes read from the file pointed to by file_pointer.Syntaxfgets (file_pointer, length);Parametersfile_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen().length − Reading ends when length - 1 bytes have been read, on a newline, or on EOF (whichever comes first).ReturnThe fgets() function returns a string of up to length - 1 bytes read from the file pointed to by fle_pointer.ExampleThe following is an example. Here, we have a file “one.txt” with ... Read More

fgetcsv() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:51:20

383 Views

The fgetcsv() function parses a line from an open file to check for CSV fields. It returns an array containing the fields read.Syntaxfgetcsv(file_pointer, length, delimiter, enclosure, escape)Parametersfile_pointer − A valid file pointer to a file successfully opened by fopen(), popen(), or fsockopen().length − Maximum length of a line.delimiter − Character that specifies the field separator. Default is comma ( , )enclosure − Set the field enclosure character. Defaults as a double quotation mark.escape − Set the escape character. Defaults as a backslash (\).ReturnThe fgetcsv() function returns an array containing the fields read.ExampleLet’s say we have the following “products.csv” CSV file.laptop, ... Read More

fgetc() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:52:14

121 Views

The fgetc() function gets a character from an open file. It returns false on eof, or a string containing a single character read from the file pointed to by file_pointerSyntaxfgetc(file_pointer)Parametersfile_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose()).ReturnThe fgetc() function returns false on eof, or a string containing a single character read from the file pointed to by file_pointer.ExampleThe following is an example. This reads the first character from the file.The following is the output. Let’s say our file “two.txt” has the text ... Read More

fflush() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:40:21

165 Views

The fflush() function flushes the output to an open file. This function forces a write of all buffered output to the resource pointed to by the file handle.Syntaxfflush(file_pointer)Parametersfile_pointer − Specify the open file stream.ReturnThe fflush() function returns.TRUE on successFALSE on failureExampleOutputtest lineLet us see another example.ExampleOutputJava is a programming language. JavaScript is a scripting language.

feof() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:40:51

193 Views

The feof() function tests for end-of-file on a file pointer. It returns TRUE if the file pointer is at EOF or an error occurs (including socket timeout); otherwise returns FALSE.Syntaxfeo(file_pointer)Parametersfile_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen() (and not yet closed by fclose())ReturnThe feof() function returns TRUE if the file pointer is at EOF or an error occurs, otherwise returns FALSE.ExampleOutputFirst line

fclose() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:41:27

401 Views

The fclose() function closes an open file pointer. The function returns TRUE on success and FALSE on failure.Syntaxfclose(file_pointer)Parametersfile_pointer − The file pointer must be valid, and must point to a file successfully opened by fopen() or fsockopen().ReturnThe fclose() function returns.TRUE on successFALSE on failureExampleOutputtrueLet us see another example. This shows a file which is opened, the content is returned using fgetsss and the file is closed with file pointer using file pointer.ExampleOutputThis is demo text

diskfreespace() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:41:52

73 Views

The diskfreespace() function returns the available free space in a directory and is an alias of disk_free_space().Syntaxdiskfreespace(dir_name)Parametersdir_name − Directory to be specified.ReturnThe diskfreespace() function returns the free space in bytes.Example Live DemoOutput832931168256Let us see another example.Example Live DemoOutputFree Space: 832931168256

disk_total_space() function in PHP

Samual Sam
Updated on 24-Jun-2020 08:42:30

91 Views

The disk_total_space() function returns the total size of a directory. It returns the total number of bytes of a directory.Syntaxdisk_total_space(dir_name)Parametersdir_name − Specify the name of the directory.ReturnThe disk_total_space() function returns the total available space in bytes.Example Live DemoOutput944459485184Let us see another example.Example Live DemoOutputTotal Available Space: 944459485184

disk_free_space() function in PHP

karthikeya Boyini
Updated on 24-Jun-2020 08:42:56

94 Views

The disk_free_space() function returns directory’s free space in bytes.Syntaxdisk_free_space(dir_name);Parametersdir_name − Specify the name of the directory.ReturnThe disk_free_space() function returns bytes of available space in a file. It returns false on failure.Example Live DemoOutput832806768640

dirname()function in PHP

Samual Sam
Updated on 24-Jun-2020 08:43:21

373 Views

The dirname() function returns the directory name from the specified path. If the path has no slashes, a dot ('.') is returned. This indicates the current directory.Syntaxdirname(file_path)Parametersfile_path − File to be specified.ReturnThe dirname() function returns the path of the directory.Example Live DemoOutputName of the directory: D:/amitLet us see another example.Example Live DemoOutputName of the directory: /amit

Advertisements