According to (1) please remind that 0777 is the [default](http://de1.php.net/mkdir) and the systems umask will be applied, too. So the created directory will never have a right of 0777, until the umask is not `0000` ;-)