Heim >Backend-Entwicklung >PHP-Tutorial > PHP读写资料代码

PHP读写资料代码

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-13 13:15:55938Durchsuche

PHP读写文件代码


<?php
    $str1 = "write something into file. ";
    $str2 = "this is a text file. ";
    $filename = "C:/data/01.txt";
    
    // 写文件
    $file = fopen($filename, "w");
    $w1 = fwrite($file, $str1);
    $w1 = fwrite($file, "\r\n");
    $w1 = fwrite($file, $str2);
    fclose($file);
    
    // 读文件
    $file = fopen($filename, "r");
    while (!feof ($file)) {  
        echo fgets($file) ."<br>" ;
    }
    fclose($file);
?>

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel: smarty中括号语法有关问题 Nächster Artikel: rewrite 正则 301转为