Home > Article > Backend Development > How to set permissions for php directory permissions
How to set permissions for php directory permissions: First create a PHP sample file; then set the owner to be readable and writable through the "chmod("test.txt",0600); method, but others will not have any permissions That’s it.
The operating environment of this tutorial: Windows 7 system, PHP version 5.6. This method is suitable for all brands of computers.
Recommended: "PHP Video Tutorial"
php method of setting directory permissions
There is a php function: chomd() ;
chmod() function changes the file mode.
chmod(file,mode) Parameter Description
file Required. Specifies the documents to be checked.
mode Optional. Specify new permissions.
The mode parameter consists of 4 numbers:
The first number is always 0
The second number specifies the owner's permissions
The second The first number specifies the permissions of the user group to which the owner belongs
The fourth number specifies the permissions of everyone else
Possible values (if you need to set multiple permissions, please adjust the numbers below Total):
1 - Execute permission
2 - Write permission
4 - Read permission
<?php // 所有者可读写,其他人没有任何权限 chmod("test.txt",0600); // 所有者可读写,其他人可读 chmod("test.txt",0644); // 所有者有所有权限,其他所有人可读和执行 chmod("test.txt",0755); // 所有者有所有权限,所有者所在的组可读 chmod("test.txt",0740); ?>
The directory is the same, change the file name into directory path
The above is the detailed content of How to set permissions for php directory permissions. For more information, please follow other related articles on the PHP Chinese website!