Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

PHP chmod() Function

PHP chmod() Function


PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual


Definition and Usage

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

Returns TRUE on success, FALSE on failure.

Syntax

chmod(file,mode)

Parameters Description
file Required. Specifies the file to check.
mode Required. Specifies the new permissions.

The mode parameter consists of 4 digits:

  • The first digit is usually 0
  • The second digit specifies the owner's permissions
  • The third digit specifies the permissions of the owner's user group
  • The fourth digit specifies the permissions for everyone else
  • Possible values (to set multiple permissions, add the numbers below together):

    |

    Example


    PHP Filesystem Reference Manual Complete PHP Filesystem Reference Manual