Notice that directory(s) and file(s) sometimes have different results.
<?php
umask(0670); $handle = fopen('file', 'w'); mkdir("/path/dir"); ?>
calculate the result:
<?php
$umask = 0670;
umask($umask);
printf( "result: %04o", $permission & ( 0777 - $umask) );
?>
BTW, as the manual said, the form of umask() is "int umask ( [int mask] )", so if you want to print/echo any umask, don't forget to convert it from DEC (because it returns a "int") to OCT.
<?php
$umask = umask(); $umask = decoct($umask); echo $umask;
?>
Don't forget that the argument(parameter) is a "int", too.
<?php
umask(777); umask(0777); ?>
If there was any mistake, please correct my statement.