ホームページ  >  記事  >  バックエンド開発  >  PHP读写资料代码

PHP读写资料代码

WBOY
WBOYオリジナル
2016-06-13 10:39:00785ブラウズ

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 までご連絡ください。