PHP chmod function Change file mode _php tutorial

Source: Internet
Author: User
When we manipulate the file, we often durable the chmod function to change the operation permissions of the specified directory.

When we manipulate the file, we often durable the chmod function to change the operation permissions of the specified directory.

Property
(PHP 4, PHP 5)

Match chmod-Change file mode

Describe
Boolean attribute (string $ file name, International $ mode)
Attempts to change the mode specified by the file to the provided mode.

Parameters

Filename
The file path.

Mode
Note that the pattern is not automatically assumed to be an octal value, so strings (such as "G + W") will not work correctly. In order to ensure the expected operation, you need the prefix mode 0 (0):

chmod ("/somedir/somefile", 755); Decimal Probably incorrect
chmod ("/somedir/somefile", "U+rwx,go+rx"); String Incorrect
chmod ("/somedir/somefile", 0755); octal; Correct value of mode
?>

The mode parameter contains three octal components that specify the owner of the access limit, and the owner of the user group is in the same order as the other person. A component can be computed, adding the necessary permissions to this target user group. Number 1 means you grant execution, number 2nd means your file is written, and number 4th means your file is readable. These numbers have been purchased to specify the rights required. You can also read more about patterns with UNIX systems ' man 1 properties ' and ' People 2 attributes.

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

Edit the recommended function:

  • 04-25php dir Function Example Tutorial
  • 04-25php chroot-Change root function
  • 04-25php chdir changing directory functions Tutorial

  • http://www.bkjia.com/PHPjc/445486.html www.bkjia.com true http://www.bkjia.com/PHPjc/445486.html techarticle when we manipulate the file, we often durable the chmod function to change the operation permission of the specified directory Oh, when we manipulate the file, we often durable the chmod function to change the operation permissions of the specified directory Oh, ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.