Easy Tutorial
❮ Pdostatement Bindvalue Php Mysql Where ❯

PHP 5 Filesystem Functions


Introduction to PHP Filesystem

Filesystem functions allow you to access and manipulate the file system.


Installation

Filesystem functions are part of the PHP core. No installation is required to use these functions.


Runtime Configuration

The behavior of Filesystem functions is affected by settings in php.ini.

Filesystem configuration options:

Name Default Description Changeable
allow_url_fopen "1" Allows fopen()-type functions to use URLs. (Available since PHP 4.0.4) PHP_INI_SYSTEM
user_agent NULL Defines the user agent that PHP will send. (Available since PHP 4.3) PHP_INI_ALL
default_socket_timeout "60" Sets the default timeout (in seconds) for socket-based streams. (Available since PHP 4.3) PHP_INI_ALL
from "" Defines the password for anonymous FTP (your email address). PHP_INI_ALL
auto_detect_line_endings "0" When set to "1", PHP will check the line ending conventions of the data retrieved by fgets() and file() to match Unix, MS-Dos, or Mac styles. (Available since PHP 4.3) PHP_INI_ALL

Unix / Windows Compatibility

When specifying paths on Unix platforms, the forward slash (/) is used as the directory separator. On Windows platforms, both forward slashes (/) and backslashes () can be used.


PHP 5 Filesystem Functions

Function Description
basename() Returns the filename from a path.
chgrp() Changes file group.
chmod() Changes file mode.
chown() Changes file owner.
clearstatcache() Clears the file status cache.
copy() Copies a file.
delete() See unlink() or unset()
dirname() Returns the directory name from a path.
disk_free_space() Returns the free space of a directory.
disk_total_space() Returns the total size of a directory.
diskfreespace() Alias of disk_free_space().
fclose() Closes an open file.
feof() Tests if the file pointer is at the end of the file.
fflush() Flushes the output to an open file.
fgetc() Returns a character from an open file.
fgetcsv() Parses a line from an open file, checking for CSV fields.
fgets() Returns a line from an open file.
fgetss() Returns a line from an open file and strips HTML and PHP tags.
file() Reads a file into an array.
file_exists() Checks if a file or directory exists.
file_get_contents() Reads a file into a string.
file_put_contents() Writes a string to a file.
fileatime() Returns the last access time of a file.
filectime() Returns the last modification time of a file.
filegroup() Returns the group ID of the file.
fileinode() Returns the inode number of the file.
filemtime() Returns the last modification time of the file's content.
fileowner() Returns the user ID (owner) of the file.
fileperms() Returns the permissions of the file.
filesize() Returns the size of the file.
filetype() Returns the type of the file.
flock() Locks or releases a file.
fnmatch() Matches a filename or string against a specified pattern.
fopen() Opens a file or URL.
fpassthru() Reads from an open file until EOF and writes the result to the output buffer.
fputcsv() Formats a line as CSV and writes it to an open file.
fputs() Alias of fwrite().
fread() Reads from an open file.
fscanf() Parses input according to a specified format.
fseek() Seeks in an open file.
fstat() Returns information about an open file.
ftell() Returns the current position in an open file.
ftruncate() Truncates an open file to a specified length.
fwrite() Writes to an open file.
glob() Returns an array of filenames/directories matching a specified pattern.
is_dir() Checks if a file is a directory.
is_executable() Checks if a file is executable.
is_file() Checks if a file is a regular file.
is_link() Checks if a file is a link.
is_readable() Checks if a file is readable.
is_uploaded_file() Determines if a file was uploaded via HTTP POST.
is_writable() Determines if a file is writable.
is_writeable() Alias of is_writable().
lchgrp() Changes group ownership of symlink.
lchown() Changes user ownership of symlink.
link() Creates a hard link.
linkinfo() Returns information about a hard link.
lstat() Returns information about a file or symbolic link.
mkdir() Creates a directory.
move_uploaded_file() Moves an uploaded file to a new location.
parse_ini_file() Parses a configuration file.
parse_ini_string() Parses a configuration string.
pathinfo() Returns information about a file path.
pclose() Closes a process opened by popen().
popen() Opens a process.
readfile() Reads a file and writes it to the output buffer.
readlink() Returns the target of a symbolic link.
realpath() Returns an absolute pathname.
realpath_cache_get() Returns cache entries.
realpath_cache_size() Returns cache size.
rename() Renames a file or directory.
rewind() Rewinds the position of a file pointer.
rmdir() Removes an empty directory.
set_file_buffer() Sets the buffer size of an open file.
stat() Returns information about a file.
symlink() Creates a symbolic link.
tempnam() Creates a unique temporary file.
tmpfile() Creates a unique temporary file.
touch() Sets access and modification time of a file.
umask() Changes file permissions.
unlink() Deletes a file.
❮ Pdostatement Bindvalue Php Mysql Where ❯