PHP chmod( ) function Change file or folder permission modes


Syntax:

chmod ( string $filename , int $permissions );

Returns true on success or false on failure.


Example:

<?php

$file = "assets/myFile.txt";

//change permission
chmod($file, 0755);
?>


Example two

<?php
// Read and write for owner, nothing for everybody else
chmod("/somedir/somefile", 0600);

// Read and write for owner, read for everybody else
chmod("/somedir/somefile", 0644);

// Everything for owner, read and execute for others
chmod("/somedir/somefile", 0755);

// Everything for owner, read and execute for owner's group
chmod("/somedir/somefile", 0750);
?>