Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function chmod()


previous

Advertisements

Syntax

bool chmod ( string $filename, int $mode );

Definition and Usage

Attempts to change the mode of the specified file to that given in mode

Paramters

ParameterDescription
pathA file path.
modeNote that mode is not automatically assumed to be an octal value, so strings (such as "g+w") will not work properly. To ensure the expected operation, you need to prefix mode with a zero (0):

Return Value

Returns TRUE on success or FALSE on failure.

Example

Following is the usage of this function:

<?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);
?>

previous Printer Friendly

Advertisements


  

Advertisements