When you use the function mkdir
with the parameter $mode
, you must pass this parameter as int
.
When you pass like string
, the PHP automatically tries to convert to int
. During this conversion, the value is modified by passing from 0775
for 755
.
This is because PHP by default does not work with Octal, unlike the command chmod
unix.
Since Linux works with this octal value, you end up missing 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)
Therefore, the recommended (The correct in fact) is to pass as whole.
mkdir("/path/to/folder", 0775, true);
Already tried to pass the way as whole and not as string? See on documentation. In fact, read about the third parameter. If you use as
true
do not need to call the function twice.– Woss