Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Filesystem Functions


previous

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.

Constant Description PHP
GLOB_BRACE    
GLOB_ONLYDIR    
GLOB_MARK    
GLOB_NOSORT    
GLOB_NOCHECK    
GLOB_NOESCAPE    
PATHINFO_DIRNAME    
PATHINFO_BASENAME    
PATHINFO_EXTENSION    
PATHINFO_FILENAME   5.2.0
FILE_USE_INCLUDE_PATH Search for filename in include_path 5.0.0
FILE_APPEND Append content to existing file.  
FILE_IGNORE_NEW_LINES Strip EOL characters 5.0.0
FILE_SKIP_EMPTY_LINES Skip empty lines 5.0.0
FILE_BINARY Binary mode 6.0.0
FILE_TEXT Text mode 6.0.0

List of Functions

PHP: indicates the earliest version of PHP that supports the function.

Function Description PHP
basename() Returns filename component of path 3
chgrp() Changes file group 3
chmod() Changes file mode 3
chown() Changes file owner 3
clearstatcache() Clears file status cache 3
copy() Copies file 3
delete() Deletes file  
dirname() Returns directory name component of path 3
disk_free_space() Returns available space in directory 4.0.7
disk_total_space() Returns the total size of a directory 4.0.7
diskfreespace() Alias of disk_free_space() 4.0.7
fclose() Closes an open file pointer 3
feof() Tests for end-of-file on a file pointer 3
fflush() Flushes the output to a file 4
fgetc() Gets character from file pointer 3
fgetcsv() Gets line from file pointer and parse for CSV fields 3
fgets() Gets line from file pointer 3
fgetss() Gets line from file pointer and strip HTML tags 3
file_exists() Checks whether a file or directory exists 3
file_get_contents() Reads entire file into a string 4.3.0
file_put_contents() Write a string to a file 5
file() Reads entire file into an array 3
fileatime() Gets last access time of file 3
filectime() Gets inode change time of file 3
filegroup() Gets file group 3
fileinode() Gets file inode 3
filemtime() Gets file modification time 3
fileowner() Gets file owner 3
fileperms() Gets file permissions 3
filesize() Gets file size 3
filetype() Gets file type 3
flock() Portable advisory file locking 3
fnmatch() Match filename against a pattern 4.0.3
fopen() Opens file or URL 3
fpassthru() Output all remaining data on a file pointer 3
fputcsv() Format line as CSV and write to file pointer 5.1.0
fputs() Alias of fwrite() 3
fread() Binary-safe file read 3
fscanf() Parses input from a file according to a format 4.0.1
fseek() Seeks on a file pointer 3
fstat() Gets information about a file using an open file pointer 4
ftell() Tells file pointer read/write position 3
ftruncate() Truncates a file to a given length 4
fwrite() Binary-safe file write 3
glob() Find pathnames matching a pattern 4.0.3
is_dir() Tells whether the filename is a directory 3
is_executable() Tells whether the filename is executable 3
is_file() Tells whether the filename is a regular file 3
is_link() Tells whether the filename is a symbolic link 3
is_readable() Tells whether the filename is readable 3
is_uploaded_file() Tells whether the file was uploaded via HTTP POST 4.0.3
is_writable() Tells whether the filename is writable 3
is_writeable() Alias of is_writable() 3
lchgrp() Changes group ownership of symlink 5.1.2
lchown() Changes user ownership of symlink 5.1.2
link() Create a hard link 3
linkinfo() Gets information about a link 3
lstat() Gives information about a file or symbolic link 3
mkdir() Makes directory 3
move_uploaded_file() Moves an uploaded file to a new location 4.0.3
parse_ini_file() Parse a configuration file 4
pathinfo() Returns information about a file path 4.0.3
pclose() Closes process file pointer 3
popen() Opens process file pointer 3
readfile() Outputs a file 3
readlink() Returns the target of a symbolic link 3
realpath() Returns canonicalized absolute pathname 4
rename() Renames a file or directory 3
rewind() Rewind the position of a file pointer 3
rmdir() Removes directory 3
set_file_buffer() Alias of stream_set_write_buffer() 3
stat() Gives information about a file 3
symlink() Creates a symbolic link 3
tempnam() Create file with unique file name 3
tmpfile() Creates a temporary file 3
touch() Sets access and modification time of file 3
umask() Changes the current umask 3
unlink() Deletes a file 3


previous Printer Friendly

Advertisements


  

Advertisements