In your PHP script you can assign your output to a variable and then use filesystem functions to create your file:
http://www.phpbuilder.com/manual/ref.filesystem.php
Alternatively, you can use control over the output buffer to capture the output of the PHP script and then write the contents to a file (see ob_start & ob_get_contents):
http://www.zend.com/zend/art/buffering.php
HTH
-- Rich Rijnders
-- Irvine, CA US