When you use the mkdir
function with the $mode
parameter, you should pass this parameter to int
.
When you pass string
, PHP automatically tries to convert to int
. During this conversion, the value is changed from 0775
to 755
.
This is because PHP, by default, does not work with Octal, unlike the Unix chmod
command.
As Linux works with this value in octal, you end up going wrong with this conversion. Example:
Value in Octal
0777 (octal) == binário 0b 111 111 111 == permissões rwxrwxrwx (== decimal 511)
Value and decimal
777 (decimal) == binário 0b 1 100 001 001 == permissões sr----x--x (== octal 1411)
So the recommended (The correct one actually) is to pass as an integer.
mkdir("/path/to/folder", 0775, true);