Instructions for using php chmod() function

怪我咯
Release: 2023-03-13 12:50:01
Original
1861 people have browsed it

chmod() FunctionChange the file mode. Return TRUE if successful, otherwise return FALSE.

Syntax

chmod(file,mode)
Copy after login
ParametersDescription
fileRequired. Specifies the documents to be checked.
mode

Optional. Specify new permissions.

mode parameter consists of 4 numbers:

  • The first number is always 0

  • The second number is specified The owner's 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 Permissions

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

  • 1 - Execute permissions

  • 2 - Write permission

  • 4 - Read permission

Note that mode will not be automatically regarded as an octal value, and strings (such as "g+w") cannot be used. To ensure correct operation, mode needs to be preceded by 0:

<?php
chmod ("/somedir/somefile", 755);   // 十进制数,可能不对
chmod ("/somedir/somefile", "u+rwx,go+rx"); // 字符串,不对
chmod ("/somedir/somefile", 0755);  // 八进制数,正确的 mode 值
?>
Copy after login

mode The parameter contains three octals The numbers specify the owner, the owner's group, and everyone's access restrictions in order. 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.

The above is the detailed content of Instructions for using php chmod() function. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!