با fopen و fwrite و fclose یا با file_put_contents مثلا اینطوری :

if (isset($_POST['text']) && (strlen(trim($_POST['text'])) > 0))
file_put_contents("path_to_file",trim($_POST['text']));

or

if (isset($_POST['text']) && (strlen(trim($_POST['text'])) > 0)){
$fh = fopen("path_to_file","w");
fwrite($fh,trim($_POST['text']));
fclose($fh);
}