Home>Article>Backend Development> How to check the permission settings of a file in php

How to check the permission settings of a file in php

青灯夜游
青灯夜游 Original
2021-11-01 18:16:11 2582browse

In PHP, you can use the fileperms() function to view the permission settings of the file. The function of this function is to obtain and return the permissions of the file or directory. The syntax is "fileperms(filename)"; if the acquisition is successful, then Returns the file's permission settings as a number.

How to check the permission settings of a file in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

In PHP, you can use the fileperms() function to view the file permission settings.

fileperms($filename)The function returns the permissions of the file or directory$filename. If successful, the permissions are returned as a number. On failure, returns FALSE.

The output result is:

How to check the permission settings of a file in php

#Note: The number representing permissions has three possible values. To set multiple permissions, you can use the following numbers. Total:

  • 1 = Execute permission

  • #2 = Write permission

  • 4 = Read permission

Example:

  • 5 = 4 1 = Read execution permission

  • 6 = 4 2 = Read and write permissions

  • 7 = 4 2 1 = Read and write execution permissions, that is, all permissions are provided

Recommended learning : "PHP Video Tutorial"

The above is the detailed content of How to check the permission settings of a file in php. For more information, please follow other related articles on the PHP Chinese website!

php
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn