php - Why does mkdir mode parameter start with 0? -


mkdir function has default value parameter mode 0777.

bool mkdir ( string $pathname [, int $mode = 0777 [, bool $recursive = false [, resource $context ]]] ) 

every example of mkdir have seen, has mode parameter starting 0. doesn't leading octal digit signify type of file?

from this page, 0 means regular file while 3 means directory.

so, shouldn't default value mode parameter in mkdir 3777 opposed 0777.

what difference between 2 modes respect mkdir. if creating regular folder, mode value should use?

you can pretty confusing information depending on whom ask. modes specify chmod, mkdir, touch , other tools create , modify file permissions tend deal lower-order permission bits, , sticky , set[ug]id bits. higher-order parts of mode, ls -l , stat output, less seen, include file type.

the rightmost 9 bits entirely occupied permissions, , next several bits related sticky, setuid , segid bits. note:

bin(0777)  =>    '0b111111111' # 9 bits, read, write, exec bin(01777) =>   '0b1111111111' # 10 bits, sticky + 0777 bin(02777) =>  '0b10111111111' # 11 bits, setgid + 0777 bin(04777) => '0b100111111111' # 12 bits, setuid + 0777 

so article little confusing considering there's no space file type fit within first 12 bits.

you seem clear on in question, posterity, leading 0 identifies value octal. if wanted specify file type, you'd have start 03….

in case, mkdir going make directory or nothing. won't make file, it's not concerned file type bit.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -