0

PHP Filesystem Functions

Posted by jujur on 5:46 AM

PHP Filesystem Functions


PHP Filesystem Introduction

The filesystem functions allow you to access and manipulate the filesystem.

Installation

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

Runtime Configuration

The behavior of the 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 work with URLs (available since PHP 4.0.4)
PHP_INI_SYSTEM
user_agent
NULL
Defines the user agent for PHP to 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 anonymous FTP password (your email address)
PHP_INI_ALL
auto_detect_line_endings
"0"
When set to "1", PHP will examine the data read by fgets() and file() to see if it is using Unix, MS-Dos or Mac line-ending characters (available since PHP 4.3)
PHP_INI_ALL


Unix / Windows Compatibility

When specifying a path on Unix platforms, the forward slash (/) is used as directory separator. However, on Windows platforms, both forward slash (/) and backslash (\) can be used.

PHP Filesystem Functions

PHP: indicates the earliest version of PHP that supports the function.
Function
Description
PHP
Returns the filename component of a path
3
Changes the file group
3
Changes the file mode
3
Changes the file owner
3
Clears the file status cache
3
Copies a file
3
delete()
See unlink() or unset()

Returns the directory name component of a path
3
Returns the free space of a directory
4
Returns the total size of a directory
4
Alias of disk_free_space()
3
Closes an open file
3
Tests for end-of-file on an open file
3
Flushes buffered output to an open file
4
Returns a character from an open file
3
Parses a line from an open file, checking for CSV fields
3
Returns a line from an open file
3
Returns a line, with HTML and PHP tags removed, from an open file
3
Reads a file into an array
3
Checks whether or not a file or directory exists
3
Reads a file into a string
4
Writes a string to a file
5
Returns the last access time of a file
3
Returns the last change time of a file
3
Returns the group ID of a file
3
Returns the inode number of a file
3
Returns the last modification time of a file
3
Returns the user ID (owner) of a file
3
Returns the permissions of a file
3
Returns the file size
3
Returns the file type
3
Locks or releases a file
3
Matches a filename or string against a specified pattern
4
Opens a file or URL
3
Reads from an open file, until EOF, and writes the result to the output buffer
3
Formats a line as CSV and writes it to an open file
5
Alias of fwrite()
3
Reads from an open file
3
Parses input from an open file according to a specified format
4
Seeks in an open file
3
Returns information about an open file
4
Returns the current position in an open file
3
Truncates an open file to a specified length
4
Writes to an open file
3
Returns an array of filenames / directories matching a specified pattern
4
Checks whether a file is a directory
3
Checks whether a file is executable
3
Checks whether a file is a regular file
3
Checks whether a file is a link
3
Checks whether a file is readable
3
Checks whether a file was uploaded via HTTP POST
3
Checks whether a file is writeable
4
Alias of is_writable()
3
Creates a hard link
3
Returns information about a hard link
3
Returns information about a file or symbolic link
3
Creates a directory
3
Moves an uploaded file to a new location
4
Parses a configuration file
4
Returns information about a file path
4
Closes a pipe opened by popen()
3
Opens a pipe
3
Reads a file and writes it to the output buffer
3
Returns the target of a symbolic link
3
Returns the absolute pathname
4
Renames a file or directory
3
Rewinds a file pointer
3
Removes an empty directory
3
Sets the buffer size of an open file
3
Returns information about a file
3
Creates a symbolic link
3
Creates a unique temporary file
3
Creates a unique temporary file
3
Sets access and modification time of a file
3
Changes file permissions for files
3
Deletes a file
3


PHP Filesystem Constants

PHP: indicates the earliest version of PHP that supports the constant.
Constant
Description
PHP
GLOB_BRACE


GLOB_ONLYDIR


GLOB_MARK


GLOB_NOSORT


GLOB_NOCHECK


GLOB_NOESCAPE


PATHINFO_DIRNAME


PATHINFO_BASENAME


PATHINFO_EXTENSION


FILE_USE_INCLUDE_PATH


FILE_APPEND


FILE_IGNORE_NEW_LINES


FILE_SKIP_EMPTY_LINES






0 Comments

Copyright Jujur Soaloon Sitangang Lipan All rights reserved. Theme by Sitanggang. | Bloggerized by Soalparna.