Ik heb het volgende scriptje gedonload vanaf de PHP.net site:


<?php
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "John Smith\n";
// Write the contents back to the file
file_put_contents($file, $current);
?>


erg vreemd maar het script blijft alles achter elkaar zetten in plaats van telkens een nieuwe regel.
Kan iemand me zeggen wat er niet klopt?
En zo?
<?php
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "John Smith" . PHP_EOL;
// Write the contents back to the file
file_put_contents($file, $current);
?>
PHP_EOL gebruiken, die heeft altijd de goede new line.
SanThe schreef op 16.06.2009 21:26
En zo?
<?php
$file = 'people.txt';
// Open the file to get existing content
$current = file_get_contents($file);
// Append a new person to the file
$current .= "John Smith" . PHP_EOL;
// Write the contents back to the file
file_put_contents($file, $current);
?>

Getest. Werkt perfect.
Klopt, wert perfect.
Werkt dat script vanaf de PHP site ook niet?
SanThe, effe postcount opkrikken?

Reageren