<? // Get the document root $doc_root = $HTTP_SERVER_VARS['DOCUMENT_ROOT']; // Set file for opening $fp = fopen("$doc_root/data.txt", 'w'); // Check if can write to file if (!$fp) { print 'Could not open desired file for writting'; } // Set what will be written to file $outputstring = "Hello World"; // Finally, write to file fwrite($fp, $outputstring); // Close the written file fclose($fp); ?>