In PHP, you can use the chmod() function to modify the file read and write permissions. The function of this function is to change the permissions of the specified file; the syntax format is "chmod(file,mode)", and the parameter file specifies the Check the file, the parameter mode specifies new permissions.
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php changes the read and write permissions of the file
Related function description:
chmod() function changes the permissions of the specified file. Returns TRUE if successful, FALSE if failed.
Syntax
chmod(file,mode)
chmod will try to change the mode of the file specified by file to that given by mode.
Parameters | Description |
---|---|
file | Required. Specifies the documents to be checked. |
mode | Required. Specify new permissions. The mode parameter consists of 4 numbers:
Possible values (if you need to set multiple permissions, please set the following Total the numbers):
|
Note: mode will not be automatically treated as an octal value, and strings (such as "g w") cannot be used. To ensure correct operation, you need to add 0 in front of the mode:
The mode parameter contains three octal numbers in order to specify the owner, the owner's group, and everyone's access restrictions. Each part can be calculated by adding the required permissions. The number 1 makes the file executable, the number 2 makes the file writable, and the number 4 makes the file readable. Add these numbers to specify the required permissions.
Recommended learning: "PHP Video Tutorial"
The above is the detailed content of How to modify file read and write permissions in php. For more information, please follow other related articles on the PHP Chinese website!