Skip to Content
PHP 5 Kochbuch, Third Edition
book

PHP 5 Kochbuch, Third Edition

by David Sklar, Adam Trachtenberg, Carsten Lucke, Matthias Brusdeylins, Ulrich Speidel, Stephan Schmidt
September 2009
Intermediate to advanced content levelIntermediate to advanced
912 pages
48h 11m
German
O'Reilly Verlag
Content preview from PHP 5 Kochbuch, Third Edition

21.5 Einen String in eine Datei schreiben

Problem

Sie wollen einen String in eine Datei schreiben.

Lösung

Verwenden Sie file_put_contents():

$maerchen = "Es war einmal ...";
file_put_contents("maerchen.txt", $maerchen);

Diskussion

Sie können den String auch an eine existierende Datei anhängen:

$string1 = "Es war einmal ";
file_put_contents("maerchen.txt", $string1);
$string2 = "vor langer Zeit ...";
file_put_contents("maerchen.txt", $string2, FILE_APPEND);

Siehe auch

„21.3 Eine Datei auf einem entfernten Server öffnen“ zum Schreiben in eine entfernte Datei; die Dokumentation zu file_put_contents() unter http://www.php.net/file-put-contents.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

PHP programmieren unter Windows

PHP programmieren unter Windows

Arno Hollosi

Publisher Resources

ISBN: 9783868993271Purchase book