
- PHP - Home
- PHP - Roadmap
- PHP - Introduction
- PHP - Installation
- PHP - History
- PHP - Features
- PHP - Syntax
- PHP - Hello World
- PHP - Comments
- PHP - Variables
- PHP - Echo/Print
- PHP - var_dump
- PHP - $ and $$ Variables
- PHP - Constants
- PHP - Magic Constants
- PHP - Data Types
- PHP - Type Casting
- PHP - Type Juggling
- PHP - Strings
- PHP - Boolean
- PHP - Integers
- PHP - Files & I/O
- PHP - Maths Functions
- PHP - Heredoc & Nowdoc
- PHP - Compound Types
- PHP - File Include
- PHP - Date & Time
- PHP - Scalar Type Declarations
- PHP - Return Type Declarations
- PHP - Operators
- PHP - Arithmetic Operators
- PHP - Comparison Operators
- PHP - Logical Operators
- PHP - Assignment Operators
- PHP - String Operators
- PHP - Array Operators
- PHP - Conditional Operators
- PHP - Spread Operator
- PHP - Null Coalescing Operator
- PHP - Spaceship Operator
- PHP Control Statements
- PHP - Decision Making
- PHP - If…Else Statement
- PHP - Switch Statement
- PHP - Loop Types
- PHP - For Loop
- PHP - Foreach Loop
- PHP - While Loop
- PHP - Do…While Loop
- PHP - Break Statement
- PHP - Continue Statement
- PHP Arrays
- PHP - Arrays
- PHP - Indexed Array
- PHP - Associative Array
- PHP - Multidimensional Array
- PHP - Array Functions
- PHP - Constant Arrays
- PHP Functions
- PHP - Functions
- PHP - Function Parameters
- PHP - Call by value
- PHP - Call by Reference
- PHP - Default Arguments
- PHP - Named Arguments
- PHP - Variable Arguments
- PHP - Returning Values
- PHP - Passing Functions
- PHP - Recursive Functions
- PHP - Type Hints
- PHP - Variable Scope
- PHP - Strict Typing
- PHP - Anonymous Functions
- PHP - Arrow Functions
- PHP - Variable Functions
- PHP - Local Variables
- PHP - Global Variables
- PHP Superglobals
- PHP - Superglobals
- PHP - $GLOBALS
- PHP - $_SERVER
- PHP - $_REQUEST
- PHP - $_POST
- PHP - $_GET
- PHP - $_FILES
- PHP - $_ENV
- PHP - $_COOKIE
- PHP - $_SESSION
- PHP File Handling
- PHP - File Handling
- PHP - Open File
- PHP - Read File
- PHP - Write File
- PHP - File Existence
- PHP - Download File
- PHP - Copy File
- PHP - Append File
- PHP - Delete File
- PHP - Handle CSV File
- PHP - File Permissions
- PHP - Create Directory
- PHP - Listing Files
- Object Oriented PHP
- PHP - Object Oriented Programming
- PHP - Classes and Objects
- PHP - Constructor and Destructor
- PHP - Access Modifiers
- PHP - Inheritance
- PHP - Class Constants
- PHP - Abstract Classes
- PHP - Interfaces
- PHP - Traits
- PHP - Static Methods
- PHP - Static Properties
- PHP - Namespaces
- PHP - Object Iteration
- PHP - Encapsulation
- PHP - Final Keyword
- PHP - Overloading
- PHP - Cloning Objects
- PHP - Anonymous Classes
- PHP Web Development
- PHP - Web Concepts
- PHP - Form Handling
- PHP - Form Validation
- PHP - Form Email/URL
- PHP - Complete Form
- PHP - File Inclusion
- PHP - GET & POST
- PHP - File Uploading
- PHP - Cookies
- PHP - Sessions
- PHP - Session Options
- PHP - Sending Emails
- PHP - Sanitize Input
- PHP - Post-Redirect-Get (PRG)
- PHP - Flash Messages
- PHP AJAX
- PHP - AJAX Introduction
- PHP - AJAX Search
- PHP - AJAX XML Parser
- PHP - AJAX Auto Complete Search
- PHP - AJAX RSS Feed Example
- PHP XML
- PHP - XML Introduction
- PHP - Simple XML Parser
- PHP - SAX Parser Example
- PHP - DOM Parser Example
- PHP Login Example
- PHP - Login Example
- PHP - Facebook Login
- PHP - Paypal Integration
- PHP - MySQL Login
- PHP Advanced
- PHP - MySQL
- PHP.INI File Configuration
- PHP - Array Destructuring
- PHP - Coding Standard
- PHP - Regular Expression
- PHP - Error Handling
- PHP - Try…Catch
- PHP - Bugs Debugging
- PHP - For C Developers
- PHP - For PERL Developers
- PHP - Frameworks
- PHP - Core PHP vs Frame Works
- PHP - Design Patterns
- PHP - Filters
- PHP - JSON
- PHP - Exceptions
- PHP - Special Types
- PHP - Hashing
- PHP - Encryption
- PHP - is_null() Function
- PHP - System Calls
- PHP - HTTP Authentication
- PHP - Swapping Variables
- PHP - Closure::call()
- PHP - Filtered unserialize()
- PHP - IntlChar
- PHP - CSPRNG
- PHP - Expectations
- PHP - Use Statement
- PHP - Integer Division
- PHP - Deprecated Features
- PHP - Removed Extensions & SAPIs
- PHP - PEAR
- PHP - CSRF
- PHP - FastCGI Process
- PHP - PDO Extension
- PHP - Built-In Functions
PHP Filesystem Functions
The Filesystem functions are used to access and manipulate the filesystem PHP provides you all the possible 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 behavior of these functions is affected by settings in php.ini.
Name | Default | Change-log |
---|---|---|
allow_url_fopen | "1" | PHP_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_SYSTEM in PHP 5. Available since PHP 5.2.0. |
user_agent | NULL | Available since PHP 4.0.3. |
default_socket_timeout | "60" | Available since PHP 4.3.0. |
from | "" | |
auto_detect_line_endings | "0" | Available 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.
Sr.No | Constant & Description | PHP |
---|---|---|
1 |
GLOB_BRACE |
|
2 |
GLOB_ONLYDIR |
|
3 |
GLOB_MARK |
|
4 |
GLOB_NOSORT |
|
5 |
GLOB_NOCHECK |
|
6 |
GLOB_NOESCAPE |
|
7 |
PATHINFO_DIRNAME |
|
8 |
PATHINFO_BASENAME |
|
9 |
PATHINFO_EXTENSION |
|
10 |
PATHINFO_FILENAME |
5.2.0 |
11 |
FILE_USE_INCLUDE_PATH Search for filename in include_path |
5.0.0 |
12 |
FILE_APPEND Append content to existing file. |
|
13 |
FILE_IGNORE_NEW_LINES Strip EOL characters |
5.0.0 |
14 |
FILE_SKIP_EMPTY_LINES Skip empty lines |
5.0.0 |
15 |
FILE_BINARY Binary mode |
6.0.0 |
16 |
FILE_TEXT Text mode |
6.0.0 |
List of Functions
PHP − indicates the earliest version of PHP that supports the function.
Sr.No | Function & Description | PHP |
---|---|---|
1 |
basename()
Returns filename component of path |
4 |
2 |
chgrp()
Changes file group |
4 |
3 |
chmod()
Changes file mode |
4 |
4 |
chown()
Changes file owner |
4 |
5 |
clearstatcache()
Clears file status cache |
4 |
6 |
copy()
Copies file |
4 |
7 |
delete()
Deletes file |
|
8 |
dirname()
Returns directory name component of path |
4 |
9 |
disk_free_space()
Returns available space in directory |
4.1.0 |
10 |
disk_total_space()
Returns the total size of a directory |
4.1.0 |
11 |
diskfreespace()
Alias of disk_free_space() |
4 |
12 |
fclose()
Closes an open file pointer |
4 |
13 |
fdatasync()
Synchronizes data to the file |
8.1.0 |
14 |
feof()
Tests for end-of-file on a file pointer |
4 |
15 |
fflush()
Flushes the output to a file |
4.0.1 |
16 |
fgetc()
Gets character from file pointer |
4 |
17 |
fgetcsv()
Gets line from file pointer and parse for CSV fields |
4 |
18 |
fgets()
Gets line from file pointer |
4 |
19 |
fgetss()
Gets line from file pointer and strip HTML tags |
4 |
20 |
file_exists()
Checks whether a file or directory exists |
4 |
21 |
file_get_contents()
Reads entire file into a string |
4.3.0 |
22 |
file_put_contents()
Write a string to a file |
5 |
23 |
file()
Reads entire file into an array |
4 |
24 |
fileatime()
Gets last access time of file |
4 |
25 |
filectime()
Gets inode change time of file |
4 |
26 |
filegroup()
Gets file group |
4 |
27 |
fileinode()
Gets file inode |
4 |
28 |
filemtime()
Gets file modification time |
4 |
29 |
fileowner()
Gets file owner |
4 |
30 |
fileperms()
Gets file permissions |
4 |
31 |
filesize()
Gets file size |
4 |
32 |
filetype()
Gets file type |
4 |
33 |
flock()
Portable advisory file locking |
4 |
34 |
fnmatch()
Match filename against a pattern |
4.3.0 |
35 |
fopen()
Opens file or URL |
4 |
36 |
fpassthru()
Output all remaining data on a file pointer |
4 |
37 |
fputcsv()
Format line as CSV and write to file pointer |
5.1.0 |
38 |
fputs()
Alias of fwrite() |
4 |
39 |
fread()
Binary-safe file read |
4 |
40 |
fscanf()
Parses input from a file according to a format |
4 |
41 |
fseek()
Seeks on a file pointer |
4 |
42 |
fstat()
Gets information about a file using an open file pointer |
4 |
43 |
ftell()
Returns the current position of the file read/write pointer |
4 |
44 |
ftruncate()
Truncates a file to a given length |
4 |
45 |
fwrite()
Binary-safe file write |
4 |
46 |
glob()
Find pathnames matching a pattern |
4.3.0 |
47 |
is_dir()
Tells whether the filename is a directory |
4 |
48 |
is_executable()
Tells whether the filename is executable |
4 |
49 |
is_file()
Tells whether the filename is a regular file |
4 |
50 |
is_link()
Tells whether the filename is a symbolic link |
4 |
51 |
is_readable()
Tells whether a file exists and is readable |
4 |
52 |
is_uploaded_file()
Tells whether the file was uploaded via HTTP POST |
4 |
53 |
is_writable()
Tells whether the filename is writable |
4 |
54 |
is_writeable()
Alias of is_writable() |
4 |
55 |
lchgrp()
Changes group ownership of symlink |
5.1.0 |
56 |
lchown()
Changes user ownership of symlink |
5.1.0 |
57 |
link()
Creates a hard link |
4 |
58 |
linkinfo()
Gets information about a link |
4 |
59 |
lstat()
Gives information about a file or symbolic link |
4 |
60 |
mkdir()
Makes directory |
4 |
61 |
move_uploaded_file()
Moves an uploaded file to a new location |
4 |
62 |
parse_ini_file()
Parse a configuration file |
4 |
63 |
pathinfo()
Returns information about a file path |
4 |
64 |
pclose()
Closes a file pointer to a pipe |
4 |
65 |
popen()
Opens process file pointer |
4 |
66 |
readfile()
Outputs a file |
4 |
67 |
readlink()
Returns the target of a symbolic link |
4 |
68 |
realpath()
Returns canonicalized absolute pathname |
4 |
69 |
realpath_cache_get()
Gets realpath cache entries |
5.3.2 |
70 |
realpath_cache_size()
Gets realpath cache size |
5.3.2 |
71 |
rename()
Renames a file or directory |
4 |
72 |
rewind()
Rewinds the position of a file pointer |
4 |
73 |
rmdir()
Removes directory |
4 |
74 |
set_file_buffer()
Alias of stream_set_write_buffer() |
4 |
75 |
stat()
Gives information about a file |
4 |
76 |
symlink()
Creates a symbolic link |
4 |
77 |
tempnam()
Creates a temporary file |
4 |
78 |
tmpfile()
Creates a temporary file |
4 |
79 |
touch()
Sets access and modification time of file |
4 |
80 |
umask()
Changes the current umask |
4 |
81 |
unlink()
Deletes a file |
4 |