If you have the PHP documentation from their site you'll find a chapter in there under the heading Filesystem Functions, which contains tonnes of ways to do it.
$variable_file = "MyFile";
$handle = fopen($variable_file.".txt" , "w"); // The "w" opens the file for writing
$string = "hello file!";
fwrite($handle, $string);
fclose($handle);
Will write $string to the file and then close it. To read from the file, use $string = fgets($handle);, and make sure you open the file with "r" for reading.
Note: If you are using windows 2000, you may need to write "\r\n" to a file instead of just the normal "\n" for a newline, I picked that up the other day on here.
~ Paul