[php] ftell() 函數在打開文件中的當前位置

例子
<?php
$file = fopen("test.txt","r");

// 輸出當前位置
echo ftell($file);

// 改變當前位置
fseek($file,"15");

// 再次輸出當前位置
echo ftell($file);

fclose($file);
?>
輸出:
0
15


<?php

// opens a file and read some data
$fp = fopen("/etc/passwd", "r");
$data = fgets($fp, 12);

// where are we ?
echo ftell($fp); // 11

fclose($fp);

?>

arrow
arrow
    全站熱搜

    stockwfj3 發表在 痞客邦 留言(0) 人氣()