why would you want your php file to be a cgi script? the functionality of PHP is more or less the same as any perl CGI script.
but, to convert it what you need to do is rename the file to .cgi, chmod it to 755, put it on your cgi-bin or have ExecCGI enabled in apache.
in the script itself, you'll need to put "#!/usr/bin/php" at the top of your file and modify the script accordingly. i'm not sure if a PHP CGI script will execute with the <?php tags in there, so they might need to be removed as well.