[PHP] fread() | wat doe ik fout?
Featured Replies
Recent actief 0
- Er zijn hier geen geregistreerde gebruikers aanwezig.
Een betere weg om onze GTA community te volgen. Leer meer.
Een volledig scherm app op het beginscherm inclusief notificaties, badges en meer.
Halloo...
Ik heb 2scripts gemaakt
'write.php' en 'read.php' waarin ik tekst in een bestand zet en de tekst er weer uit lees.
alleen als ik tekst in de file schrijf, en daarna nog een keer komt er dit in de file te staan
en bij het uitlezen komt er helemaal niks te staan..
hoe fix je dit?
// write.php <?php echo "Start"; $bestand = 'test.txt'; $tekst = "Test tekst. /n"; if (is_writable($bestand)) { if (!$handle = fopen($bestand, 'a')) { echo "kan het bestand $bestand niet openen"; exit; } if (fwrite($handle, $tekst) === FALSE) { echo "kan niet scrijfen naar het bestand $bestand)"; exit; } echo "$tekst is opgeslagen in $bestand"; fclose($handle); } else { echo "kan niet schrijven in het bestand $bestand"; } ?>// read.php <?php $bestand = "test.txt"; if (file_exists($bestand)) { $txt = fopen($bestand, "r"); echo "Het bestand $bestand bestaat en is geladen"; echo "/n"; echo "De tekst is:"; echo "/n"; echo "%txt"; fclose($txt); } else { echo "Het bestand $bestand bestaat niet"; } ?>Bewerkt: door Crusher!!