Set file attributes created with PHP fopen

How do i set attributes to 777 when creating files with PHP fopen function?

$fp = fopen( $filename,“w+”);