Home  >  Article  >  Backend Development  >  How to set permissions in php?

How to set permissions in php?

烟雨青岚
烟雨青岚Original
2020-06-13 10:48:414153browse

How to set permissions in php?

#php method to set permissions: chmod() function.

chmod() function changes the file mode. chmod — Changes file mode Returns TRUE if successful, FALSE otherwise.

Syntax: chmod(file,mode)

<?php
chmod("/somedir/somefile", 0755); // 八进制数,正确的 mode 值
?>

Parameter description:

file (required): Specifies the file to be checked.

mode (optional):

Specifies new permissions.

The mode parameter consists of 4 numbers:

The first number is always 0

The second number specifies the owner Permissions

The second number specifies the permissions of the user group to which the owner belongs

The fourth number specifies the permissions of everyone else

Possible values ​​(to set multiple permissions, please total the numbers below):

1 - Execute permissions

2 - Write permissions

4 - Read permission

How to set permissions in php?

Recommended tutorial: "php tutorial"

The above is the detailed content of How to set 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