Home >Backend Development >PHP Tutorial >Instructions for using php chmod() function
chmod() FunctionChange the file mode. Return TRUE if successful, otherwise return FALSE.
Syntax
chmod(file,mode)
Parameters | Description |
---|---|
file | Required. Specifies the documents to be checked. |
mode |
Optional. Specify new permissions. mode parameter consists of 4 numbers:
Possible values (to set multiple permissions, total the numbers below):
|
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 值 ?>
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!