php入門學(xué)習(xí)知識(shí)點(diǎn)六PHP文件的讀寫操作代碼

字號(hào):


    php入門學(xué)習(xí)知識(shí)點(diǎn)六PHP文件的讀寫操作代碼,讀取文件內(nèi)容可以用以下兩個(gè)函數(shù)進(jìn)行操作fread,file_get_contents
    代碼如下:
    <?php
    //打開文件
    $fp=fopen('tmp.html','r');
    //讀取文件內(nèi)容可以用以下兩個(gè)函數(shù)進(jìn)行操作fread,file_get_contents
    $str=fread($fp,filesize('tmp.html'));//filesize為獲取文件大小
    $content=file_get_contents('tmp.html');
    //寫文件
    $news=fopen('news.html','w');
    fwrite($news,$content);
    //關(guān)閉文件流
    fclose($fp);
    fclose($news);
    echo$content;
    ?>