Current Location: Home> Function Categories> chmod

chmod

Change file mode
Name:chmod
Category:File system
Programming Language:php
One-line Description:Change file mode.

Definition and usage

chmod() function changes the file mode.

Return TRUE if successful, otherwise return FALSE.

Example

 <?php
// The owner can read and write, and others do not have any permissions
chmod ( "test.txt" , 0600 ) ;

// The owner can read and write, and others can read
chmod ( "test.txt" , 0644 ) ;

// The owner has all permissions, which can be read and executed by everyone else
chmod ( "test.txt" , 0755 ) ;

// The owner has all permissions, and the group where the owner is located can be readable
chmod ( "test.txt" , 0740 ) ;
?>

grammar

 chmod ( file , mode )
parameter describe
file Required. Specify documents to be inspected.
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 number specifies the permissions of the user group to which the owner belongs
  • The fourth number stipulates the authority of everyone else

Possible values ​​(If you need to set multiple permissions, total the following numbers):

  • 1 - Execution permissions
  • 2 - Write permission
  • 4 - Read permissions
Similar Functions