0% found this document useful (0 votes)
66 views

Moodle File Functions

This document summarizes common PHP functions related to files, including functions to read files like file(), is_readable(), and file_get_contents(); write files like tempname(), file_put_contents(), and fputcsv(); and manage temporary files like tmpfile(). These functions provide easy ways to work with files from within PHP programs.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
66 views

Moodle File Functions

This document summarizes common PHP functions related to files, including functions to read files like file(), is_readable(), and file_get_contents(); write files like tempname(), file_put_contents(), and fputcsv(); and manage temporary files like tmpfile(). These functions provide easy ways to work with files from within PHP programs.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 1

Functions Related to file

Function Name Description


Given a filename returns the array as line
of file.
file($filename)
Function is standard function working for
php 4 and 5 version.

Checks whether the file at a given path is


is_readable($filename) valid and readable or not
@return true/false

tmpfile() Create a temporary file

Create file with unique file name.

@dir = The directory where the temporary


tempname($dir,$prefix)
filename will be created.
@prefix = The prefix of the generated
temporary filename.

Read the file and return the content of file


file_get_contents($filename, $flags = in String format.
null, $context = null, $offset = null,
$maxlen = null) @return The function returns the read data
or false on failure.

Writes a String to a file


file_put_contents($filename, $data,
@return int The function returns the number
$flags = null, $context = null)
of bytes that were written to the file, or
false on failure.

fgetcsv Reads the CSV file

Write the content as CSV format to the CSV


fputcsv
file.

You might also like