Home  >  Article  >  Backend Development  >  How to modify file permissions in php?

How to modify file permissions in php?

青灯夜游
青灯夜游Original
2020-11-05 15:19:412856browse

In PHP, you can use the built-in function chmod() to modify the permissions of the file; this function can change the permissions of the specified file. The syntax format is "chmod(file,mode)". If the modification is successful, it returns TRUE. , and returns FALSE if it fails.

How to modify file permissions in php?

Recommended: "PHP Video Tutorial"

PHP chmod() function can change the permissions of the specified file; if Returns TRUE on success and FALSE on failure.

chmod will try to change the mode of the file specified by file to that given by mode.

chmod(file,mode)

Parameters:

How to modify file permissions in php?

Note: mode will not be automatically treated as an octal value, and it cannot use strings (such as " g w"). 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. For information about file permissions on UNIX systems, read the manuals "man 1 chmod" and "man 2 chmod".

For more programming-related knowledge, please visit: Programming Video! !

The above is the detailed content of How to modify file permissions in php?. For more information, please follow other related articles on the PHP Chinese website!

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