In PHP, why won't this write to test.txt?
问题 My code is <?php $fp = fopen('test.txt', "a+"); fwrite($fp, 'Cats chase mice'); fclose($fp); ?> but test.txt is still empty. I don't see anything wrong and I don't understand why it's not writing. 回答1: Write this in a console chmod a+w test.txt 回答2: This is a file permissions issue. This will chmod your file to 777 making it writeable. Tested on Linux server: <?php $fp = fopen('test.txt', "a+"); chmod("test.txt", 0777); // try also 0666 or 0644 fwrite($fp, 'Cats chase mice'); fclose($fp); ?>