首頁  >  文章  >  後端開發  >  PHP读写资料代码

PHP读写资料代码

WBOY
WBOY原創
2016-06-13 10:39:00783瀏覽

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);?>

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn