PHP Write Text in file

Write Text in file

<?
$string = "test";
$open = fopen("test.txt", 'a');
fwrite($open,"$string\n");
fclose($open);
?>