I have this code:
$file = '/path/to/file.txt';
if (($fd = fopen($file, "a") !== false)) {
fwrite($fd, 'message to be written' . "\n");
fclose($fd);
}
Why do I get the following warnings?
fwrite(): supplied argument is not a valid stream resource
fclose(): supplied argument is not a valid stream resource
Your if statement is wrong. Try
Because yours one is like