chmod() function:

chmod() function:

PHP’s chmod() function used to change the file mode. We can use this chmod() function as follows.

chmod(”filename”, intval(0777, 8) );
Notice that we’re passing an octal value to the chmod() function. We get the octal value by using PHP’s intval() function to which we pass our hexadecimal value that represents the rights that we want to assign to the file.

And here is how to calculate the permission levels
(after calculating the permission levels, we have to add a 0 as prefix, thus making it a hexadecimal number):

- 400 Owner Read
- 200 Owner Write
- 100 Owner Execute
- 40 Group Read
- 20 Group Write
- 10 Group Execute
- 4 Global Read
- 2 Global Write
- 1 Global Execute

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.