Get the App
SLTechnology News&Howtos  ›  Development  › 

Basic operation of PHP file directory

Shulou Source: shulou.com Published: 2022-06-03 19:56:25 11月12日 Update

This article mainly explains the "basic operation of the PHP file directory", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn the "basic operation of the PHP file directory" bar!

1. Get the attribute information of the file

First of all, files have types. Under Linux, there are block (block devices, such as disk partitions, CD-ROM), char (devices input by characters, such as keyboards, printers), dir (directory types, directories are also a kind of files), fifo (named pipes, which means passing information from one process to another), file (ordinary files), and link (links). Similar to the shortcuts under win), unknow (unknown type) 7 categories, under win, there are only 3 categories: file, dir and unknown. Linux scum said that we must do a good job on Linux-_-,. The family was born for Linux.

There are several functions for type acquisition: filetype: get the type; is_file: determine whether it is a normal file; is_link: determine whether it is a link.

There are several functions for getting attributes:

File_exists: determines whether a file or directory exists

Filesize: get file size

Is_readable, is_writable, is_executable: readable, writable, executable

Filectime, filemtime, fileatime: get the creation time (create), modification time (modify) and access time (access) of the file, and all return timestamps

Stat: gets some basic information about the file and returns a mixed array of indexes and associations.

For example, you can determine the file type as follows:

The copy code is as follows:

Tags: File directory code content size function time type processing permission user handle byte pointer effect end base location that is system Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn Linux Shulou Information Shulou Technology MySQL