I want to Chmod a file so it is writeable, and then restore it's old permissions. Will fileperms return the original permissions, and then can I chmod the file with what it returns like so:

PHP Code:
<?php
$perms 
fileperms('./FILENAME.php');
chmod('./FILENAME'0777);
chmod('./FILENAME'$perms);
?>
I was told I may need to convert $perms to octal, is that righ?