Web | This Site

Learning PHP
Advanced PHP
PHP Function Reference
PHP Useful Resources
Selected Reading
© 2011 TutorialsPoint.COM

| Home |  | References |  | Discussion Forums |  | About TP

# PHP Function chmod()

## 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

Parameter | Description
--- | ---
path | A file path.
mode | Note 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);
    ?>

Advertisement

Online Image Processing

Indian Baby Names