PHP chmod() Function
❮ PHP Filesystem ReferenceExample
Change permissions for the "test.txt" file:
<?php
// Read and write for owner, nothing for everybody else
chmod("test.txt",0600);
// Read and write for owner, read for everybody else
chmod("test.txt",0644);
// Everything for owner, read and execute for everybody else
chmod("test.txt",0755);
// Everything for owner, read for owner's group
chmod("test.txt",0740);
?>
Definition and Usage
The chmod() function changes permissions of the specified file.
Syntax
chmod(file, mode)
Parameter Values
Parameter | Description |
---|---|
file | Required. Specifies the path to the file |
mode | Required. Specifies the new permissions. The mode parameter consists of four numbers:
Possible values (to set multiple permissions, add up the following numbers):
|
Technical Details
Return Value: | TRUE on success, FALSE on failure |
---|---|
PHP Version: | 4.0+ |
❮ PHP Filesystem Reference
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.