PHP chmod() Function
Definition and Usage
The chmod() function changes the file mode.
Returns TRUE on success, otherwise returns FALSE.
Syntax
chmod(file,mode)
Parameters | Description |
---|---|
file | Required. Specifies the file to be checked. |
mode |
Optional. Specifies the new permissions. The mode parameter consists of 4 numbers:
Possible Values (if multiple permissions need to be set, sum the following numbers):
|
Example
<?php // Owner can read and write, other users have no permissions chmod("test.txt",0600); // Owner can read and write, other users can read chmod("test.txt",0644); // Owner has all permissions, other users can read and execute chmod("test.txt",0755); // Owner has all permissions, group members of the owner can read chmod("test.txt",0740); ?>