Uber simple example to illustrate the point:
$message = $_POST[\'message\'];
$fp = fopen(\"log.txt\", \"a\");
fwrite($fp, $message);
fclose($fp);
>
You should sanitize user input, but how is entirely dependent on what the input is for. "Sanitizing" refers to the idea of making sure input is safe or sane for a particular use. The term cannot be more specific until you settle on use cases.
You don't need to worry about the PHP reading/writing functions like fopen(). Be concerned with steps that actually parse or analyze the input. Some possible examples: