Home > Article > Backend Development > How to check the permission settings of a file in php
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.
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.
<?php header("content-type:text/html;charset=utf-8"); $filename = "test.txt"; echo "{$filename} 文件的权限为:".fileperms($filename); ?>
The output result is:
#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!