chmod() function:
PHP’s chmod() function used to change the file mode. We can use this chmod() function as follows.
chmod(”filename”, intval(0777,
);
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
