PHP Filesystem Functions

EditRocket provides the following information on Filesystem functions in the PHP source code builder.

string basename ( string $path [, string $suffix ] ) - Given a string containing a path to a file, this function will return the base name of the file.

bool chgrp ( string $filename , mixed $group ) - Attempts to change the group of the file filename to group.

bool chmod ( string $filename , int $mode ) - Attempts to change the mode of the specified file to that given in mode.

bool chown ( string $filename , mixed $user ) - Attempts to change the owner of the file filename to user user. Only the superuser may change the owner of a file.

void clearstatcache ( void ) -

bool copy ( string $source , string $dest [, resource $context ] ) - Makes a copy of the file source to dest.

void delete ( void ) -

string dirname ( string $path ) - Given a string containing a path to a file, this function will return the name of the directory.

float disk_free_space ( string $directory ) - Given a string containing a directory, this function will return the number of bytes available on the corresponding filesystem or disk partition.

float disk_total_space ( string $directory ) - Given a string containing a directory, this function will return the total number of bytes on the corresponding filesystem or disk partition.

-

bool fclose ( resource $handle ) - The file pointed to by handle is closed.

bool feof ( resource $handle ) - Tests for end-of-file on a file pointer.

bool fflush ( resource $handle ) - This function forces a write of all buffered output to the resource pointed to by the file handle.

string fgetc ( resource $handle ) - Gets a character from the given file pointer.

array fgetcsv ( resource $handle [, int $length [, string $delimiter [, string $enclosure [, string $escape ]]]] ) -

string fgets ( resource $handle [, int $length ] ) - Gets a line from file pointer.

string fgetss ( resource $handle [, int $length [, string $allowable_tags ]] ) -

array file ( string $filename [, int $flags [, resource $context ]] ) - Reads an entire file into an array.

bool file_exists ( string $filename ) - Checks whether a file or directory exists.

string file_get_contents ( string $filename [, int $flags [, resource $context [, int $offset [, int $maxlen ]]]] ) -

int file_put_contents ( string $filename , mixed $data [, int $flags [, resource $context ]] ) -

int fileatime ( string $filename ) -

int filectime ( string $filename ) - Gets the inode change time of a file.

int filegroup ( string $filename ) - Gets the file group.

int fileinode ( string $filename ) - Gets the file inode.

int filemtime ( string $filename ) - This function returns the time when the data blocks of a file were being written to, that is, the time when the content of the file was changed.

int fileowner ( string $filename ) - Gets the file owner.

int fileperms ( string $filename ) - Gets permissions for the given file.

int filesize ( string $filename ) - Gets the size for the given file.

string filetype ( string $filename ) - Returns the type of the given file.

bool flock ( resource $handle , int $operation [, int &$wouldblock ] ) - flock() allows you to perform a simple reader/writer model which can be used on virtually every platform (including most Unix derivatives and even Windows).

bool fnmatch ( string $pattern , string $string [, int $flags ] ) - fnmatch() checks if the passed string would match the given shell wildcard pattern.

resource fopen ( string $filename , string $mode [, bool $use_include_path [, resource $context ]] ) - fopen() binds a named resource, specified by filename, to a stream.

int fpassthru ( resource $handle ) - Reads to EOF on the given file pointer from the current position and writes the results to the output buffer.

int fputcsv ( resource $handle , array $fields [, string $delimiter [, string $enclosure ]] ) - fputcsv() formats a line (passed as a fields array) as CSV and write it (terminated by a newline) to the specified file handle.

-

string fread ( resource $handle , int $length ) - fread() reads up to length bytes from the file pointer referenced by handle. Reading stops as soon as one of the following conditions is met: length bytes have been read. EOF (end of file) is reached. a packet becomes available (for network streams). 8192 bytes have been read (after opening userspace stream)

mixed fscanf ( resource $handle , string $format [, mixed &$... ] ) -

int fseek ( resource $handle , int $offset [, int $whence ] ) - Sets the file position indicator for the file referenced by handle. The new position, measured in bytes from the beginning of the file, is obtained by adding offset to the position specified by whence.

array fstat ( resource $handle ) - Gathers the statistics of the file opened by the file pointer handle.

int ftell ( resource $handle ) - Tells the file pointer read/write position.

bool ftruncate ( resource $handle , int $size ) - Takes the filepointer, handle, and truncates the file to length, size.

int fwrite ( resource $handle , string $string [, int $length ] ) -

array glob ( string $pattern [, int $flags ] ) - The glob() function searches for all the pathnames matching pattern according to the rules used by the libc glob() function, which is similar to the rules used by common shells.

bool is_dir ( string $filename ) - Tells whether the given filename is a directory.

bool is_executable ( string $filename ) - Tells whether the filename is executable.

bool is_file ( string $filename ) - Tells whether the given file is a regular file.

bool is_link ( string $filename ) - Tells whether the given file is a symbolic link.

bool is_readable ( string $filename ) - Tells whether the filename is readable.

bool is_uploaded_file ( string $filename ) - Returns TRUE if the file named by filename was uploaded via HTTP POST. This is useful to help ensure that a malicious user hasn't tried to trick the script into working on files upon which it should not be working--for instance, /etc/passwd.

bool is_writable ( string $filename ) - Returns TRUE if the filename exists and is writable. The filename argument may be a directory name allowing you to check if a directory is writable.

-

bool lchgrp ( string $filename , mixed $group ) - Attempts to change the group of the symlink filename to group.

bool lchown ( string $filename , mixed $user ) - Attempts to change the owner of the symlink filename to user user.

bool link ( string $target , string $link ) - link() creates a hard link.

int linkinfo ( string $path ) - Gets information about a link.

array lstat ( string $filename ) - Gathers the statistics of the file or symbolic link named by filename.

bool mkdir ( string $pathname [, int $mode [, bool $recursive [, resource $context ]]] ) - Attempts to create the directory specified by pathname.

bool move_uploaded_file ( string $filename , string $destination ) - This function checks to ensure that the file designated by filename is a valid upload file (meaning that it was uploaded via PHP's HTTP POST upload mechanism). If the file is valid, it will be moved to the filename given by destination.

array parse_ini_file ( string $filename [, bool $process_sections ] ) - parse_ini_file() loads in the ini file specified in filename, and returns the settings in it in an associative array.

mixed pathinfo ( string $path [, int $options ] ) - pathinfo() returns an associative array containing information about path.

int pclose ( resource $handle ) -

resource popen ( string $command , string $mode ) - Opens a pipe to a process executed by forking the command given by command.

int readfile ( string $filename [, bool $use_include_path [, resource $context ]] ) - Reads a file and writes it to the output buffer.

string readlink ( string $path ) - readlink() does the same as the readlink C function.

string realpath ( string $path ) - realpath() expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in the input path. and return the canonicalized absolute pathname.

bool rename ( string $oldname , string $newname [, resource $context ] ) - Attempts to rename oldname to newname.

bool rewind ( resource $handle ) - Sets the file position indicator for handle to the beginning of the file stream.

bool rmdir ( string $dirname [, resource $context ] ) - Attempts to remove the directory named by dirname. The directory must be empty, and the relevant permissions must permit this.

-

array stat ( string $filename ) - Gathers the statistics of the file named by filename. If filename is a symbolic link, statistics are from the file itself, not the symlink.

bool symlink ( string $target , string $link ) - symlink() creates a symbolic link to the existing target with the specified name link.

string tempnam ( string $dir , string $prefix ) - Creates a file with a unique filename, with access permission set to 0600, in the specified directory. If the directory does not exist, tempnam() may generate a file in the system's temporary directory, and return the name of that.

resource tmpfile ( void ) - Creates a temporary file with a unique name in read-write (w+) mode and returns a file handle .

bool touch ( string $filename [, int $time [, int $atime ]] ) - Attempts to set the access and modification times of the file named in the filename parameter to the value given in time. Note that the access time is always modified, regardless of the number of parameters.

int umask ([ int $mask ] ) - umask() sets PHP's umask to mask & 0777 and returns the old umask. When PHP is being used as a server module, the umask is restored when each request is finished.

bool unlink ( string $filename [, resource $context ] ) - Deletes filename. Similar to the Unix C unlink() function.