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
  • Returns the file path information pathinfo

    pathinfo

    Returnsthefilepathin
  • Close an open file pointer fclose

    fclose

    Closeanopenfilepoint
  • Determine whether the given file name is a symbolic connection is_link

    is_link

    Determinewhethertheg
  • Read the entire file into an array file

    file

    Readtheentirefileint
  • alias for stream_set_write_buffer set_file_buffer

    set_file_buffer

    aliasforstream_set_w
  • Create a temporary file tmpfile

    tmpfile

    Createatemporaryfile
  • Provide information about the document stat

    stat

    Provideinformationab
  • Format input from a file fscanf

    fscanf

    Formatinputfromafile
Popular Articles