[man]fopen/man
[man]fwrite/man
[man]fclose/man
Use those like:
<?php
$filename = 'my_test.txt';
$path = './';
$string = 'My test string of information!!';
$fh = fopen($path.$filename, "w");
if(fwrite($string) != FALSE)
{
echo 'Successfully written!!';
}
else
{
echo 'Nope, didn\'t write....';
}
fclose($fh);
?>
Other examples are noted in the PHP manual (just follow the links).