PHP chmod() Function

The chmod() function changes permissions of the specified file.

Returns TRUE on success and FALSE on failure.

bool chmod ( string $filename , int $mode )

Attempts to change the mode of the specified file to that given in mode.

Example -

ParameterDescription
fileRequired. Specifies the file to check
modeRequired. Specifies the new permissions.
fileThe mode parameter consists of four numbers:
  • The first number is always zero
  • The second number specifies permissions for the owner
  • The third number specifies permissions for the owner's user group
  • The fourth number specifies permissions for everybody else
  • Possible values (to set multiple permissions, add up the following numbers):
  • 1 = execute permissions
  • 2 = write permissions
  • 4 = read permissions