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 you need to set multiple permissions, please sum the following numbers):
|
Example
<?php // The owner can read and write, others have no permissions chmod("test.txt",0600); // The owner can read and write, others can read chmod("test.txt",0644); // The owner has all permissions, others can read and execute chmod("test.txt",0755); // The owner has all permissions, the group the owner belongs to can read chmod("test.txt",0740); ?>