I'm currently trying to write to a txt-file with PHP, I've found this small script:
<?php
$filename = 'testFile.txt';
$somecontent = "Add this to the file\n";
if (is_writable($filename)) {
if (!$handle = fopen($filename, 'a')) {
echo "Cannot open file ($filename)";
exit;
}
if (fwrite($handle, $somecontent) === FALSE) {
echo "Cannot write to file ($filename)";
exit;
}
echo "Success, wrote ($somecontent) to file ($filename)";
fclose($handle);
}
else {
echo "The file $filename is not writable";
}
?>
I get a success-message, but nothing is written to the file. Even if I delete the txt-file I still get the success-message
Does anybody know how to troubleshoot a situation like this?