#30 ファイルからデータを読み出す (1)

 
fopen( )
 
    
    if (!$fp = fopen($testFile, "r")) {
        echo "could not open";
        exit;
    }

  ファイルオープンモード一覧 )
 
fread( )
 

    $contents = fread($fp, filesize($testFile));

 
〜実行〜
 
    $testFile = "test.dat";

    if (!$fp = fopen($testFile, "r")) {
        echo "could not open";
        exit;
    }

    $contents = fread($fp, filesize($testFile)); <-- 最大サイズまで読み込んで"$contents"に返す  

    var_dump($contents);

    fclose($fp);
 

PAGE TOP

< 前へ 目次に戻る 次へ >