File Operations (PHP)

Source: Internet
Author: User

1. Determine the file type (file OR directory):

FileType (); Returns the type of file: directory dir; file
Is_dir (); Determine if the path is a directory
Is_file (); Determine if the path is not a file

2. Get the properties of a file

Date ("Y-m-d h:i:s", Fileatime ()); Time of last visit
Date ("Y-m-d h:i:s", Filectime ()); File creation time
Date ("Y-m-d h:i:s", Filemtime ()); File modification Time
FileSize (); File size in bytes
File_exists (); Determine if a file exists

3. File path

Current path:./parent directory:. /Subordinate Directory: Directory/root path:/

If it is the root (/) path inside PHP: The root of the disk
If the root (/) path inside the Web page represents: root of the server (WWW directory)

$_server[' Document_root ']; Fetch the root path of the server
BaseName (); Get the filename with a suffix from the path
DirName (); The path before the filename is taken
PathInfo (); Get all information about the directory (in the form of an array)
Realpath (); Convert a relative path to an absolute path

4. Operation Catalogue

Glob (".. /tp/* "); Get all the files in this directory
Glob (".. /tp/*.php "); Get all files with the suffix. PHP under this directory
Dirsize (); Calculate Folder Size
Opendir (); Open Directory Resource
Closedir (); Close Directory Resource
Readdir (); Read the file in the directory, perform a read one
Rewinddir (); Pointer reset

File Operations (PHP)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.