Introduction to the PHP chmod () function

Source: Internet
Author: User
php chmod function can change the access rights of files and folders, but when using the prompt warning, as follows:

Warning:chmod () [Function.chmod]: Operation not permitted in/export/mytest/chmodtest.php on line 5

The modified folder has all the parent folder's access permissions changed to the 777,chmod function does not modify the access permissions of the folder at all, what is the reason? *nix just let all the files under the Web root belong to Apache run user all right, fake Apache user with Apache group running httpd Then

Chown-r Apache.apache/path to documentroot/

Win has all permissions to the IIS running user to DocumentRoot.

The chmod () function changes the file mode. returns TRUE if successful, otherwise FALSE.

Grammar

chmod (File,mode)


Parameters Description
File Necessary. Specifies the documents to be inspected.
Mode

Optional. Specify the new permissions.

The mode parameter consists of 4 numbers:

  • The first number is always 0.

  • The second number specifies the owner's permissions

  • The second number specifies the permissions of the user group to which the owner is a member

  • The fourth number stipulates the rights of all other persons

Possible values (if you want to set multiple permissions, make a total of the following numbers):

  • 1-Execute Permissions

  • 2-Write permissions

  • 4-Read Permissions

PHP chmod () function instance

The <?php//owner can read and write, others do not have any permissions chmod ("Test.txt", 0600);//The owner can read and write, the other person is readable chmod ("test.txt", 0644);//owner has all permissions, All other persons can read and execute chmod ("Test.txt", 0755);//owner has all permissions, the owner of the group is readable chmod ("test.txt", 0740); >
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.