Wednesday, 28 August 2013

PHP Filesystem Functions

The filesystem functions are used to access and manipulate the filesystem PHP provides you all the posible functions you may need to manipulate a file.

Installation:

The error and logging functions are part of the PHP core. There is no installation needed to use these functions.

Runtime Configuration:

The behaviour of these functions is affected by settings in php.ini.
NameDefaultChangeableChangelog
allow_url_fopen"1"PHP_INI_ALLPHP_INI_ALL in PHP <= 4.3.4. PHP_INI_SYSTEM in PHP < 6. Available since PHP 4.0.4.
allow_url_include"0"PHP_INI_ALLPHP_INI_SYSTEM in PHP 5. Available since PHP 5.2.0.
user_agentNULLPHP_INI_ALLAvailable since PHP 4.0.3.
default_socket_timeout"60"PHP_INI_ALLAvailable since PHP 4.3.0.
from""PHP_INI_ALL
auto_detect_line_endings"0"PHP_INI_ALLAvailable since PHP 4.3.0.

PHP Error and Logging Constants:

PHP: indicates the earliest version of PHP that supports the constant.
You can use any of the constant while configuring your php.ini file.
ConstantDescriptionPHP
GLOB_BRACE
GLOB_ONLYDIR
GLOB_MARK
GLOB_NOSORT
GLOB_NOCHECK
GLOB_NOESCAPE
PATHINFO_DIRNAME
PATHINFO_BASENAME
PATHINFO_EXTENSION
PATHINFO_FILENAME5.2.0
FILE_USE_INCLUDE_PATHSearch for filename in include_path5.0.0
FILE_APPENDAppend content to existing file.
FILE_IGNORE_NEW_LINESStrip EOL characters5.0.0
FILE_SKIP_EMPTY_LINESSkip empty lines5.0.0
FILE_BINARYBinary mode6.0.0
FILE_TEXTText mode6.0.0

List of Functions

PHP: indicates the earliest version of PHP that supports the function.
FunctionDescriptionPHP
basename()Returns filename component of path3
chgrp()Changes file group3
chmod()Changes file mode3
chown()Changes file owner3
clearstatcache()Clears file status cache3
copy()Copies file3
delete()Deletes file
dirname()Returns directory name component of path3
disk_free_space()Returns available space in directory4.0.7
disk_total_space()Returns the total size of a directory4.0.7
diskfreespace()Alias of disk_free_space()4.0.7
fclose()Closes an open file pointer3
feof()Tests for end-of-file on a file pointer3
fflush()Flushes the output to a file4
fgetc()Gets character from file pointer3
fgetcsv()Gets line from file pointer and parse for CSV fields3
fgets()Gets line from file pointer3
fgetss()Gets line from file pointer and strip HTML tags3
file_exists()Checks whether a file or directory exists3
file_get_contents()Reads entire file into a string4.3.0
file_put_contents()Write a string to a file5
file()Reads entire file into an array3
fileatime()Gets last access time of file3
filectime()Gets inode change time of file3
filegroup()Gets file group3
fileinode()Gets file inode3
filemtime()Gets file modification time3
fileowner()Gets file owner3
fileperms()Gets file permissions3
filesize()Gets file size3
filetype()Gets file type3
flock()Portable advisory file locking3
fnmatch()Match filename against a pattern4.0.3
fopen()Opens file or URL3
fpassthru()Output all remaining data on a file pointer3
fputcsv()Format line as CSV and write to file pointer5.1.0
fputs()Alias of fwrite()3
fread()Binary-safe file read3
fscanf()Parses input from a file according to a format4.0.1
fseek()Seeks on a file pointer3
fstat()Gets information about a file using an open file pointer4
ftell()Tells file pointer read/write position3
ftruncate()Truncates a file to a given length4
fwrite()Binary-safe file write3
glob()Find pathnames matching a pattern4.0.3
is_dir()Tells whether the filename is a directory3
is_executable()Tells whether the filename is executable3
is_file()Tells whether the filename is a regular file3
is_link()Tells whether the filename is a symbolic link3
is_readable()Tells whether the filename is readable3
is_uploaded_file()Tells whether the file was uploaded via HTTP POST4.0.3
is_writable()Tells whether the filename is writable3
is_writeable()Alias of is_writable()3
lchgrp()Changes group ownership of symlink5.1.2
lchown()Changes user ownership of symlink5.1.2
link()Create a hard link3
linkinfo()Gets information about a link3
lstat()Gives information about a file or symbolic link3
mkdir()Makes directory3
move_uploaded_file()Moves an uploaded file to a new location4.0.3
parse_ini_file()Parse a configuration file4
pathinfo()Returns information about a file path4.0.3
pclose()Closes process file pointer3
popen()Opens process file pointer3
readfile()Outputs a file3
readlink()Returns the target of a symbolic link3
realpath()Returns canonicalized absolute pathname4
rename()Renames a file or directory3
rewind()Rewind the position of a file pointer3
rmdir()Removes directory3
set_file_buffer()Alias of stream_set_write_buffer()3
stat()Gives information about a file3
symlink()Creates a symbolic link3
tempnam()Create file with unique file name3
tmpfile()Creates a temporary file3
touch()Sets access and modification time of file3
umask()Changes the current umask3
unlink()Deletes a file3

No comments:

Post a Comment