Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
43 lines (39 sloc) 714 Bytes
<?php
$fp = fopen("sample_text.txt", 'r');
$res = fgets($fp);
var_dump($res);
var_dump(stream_get_meta_data($fp));
#"
#array(9) {
# ["timed_out"]=>
# bool(false)
# ["blocked"]=>
# bool(true)
# ["eof"]=>
# bool(false)
# ["wrapper_type"]=>
# string(9) "plainfile"
# ["stream_type"]=>
# string(5) "STDIO"
# ["mode"]=>
# string(1) "r"
# ["unread_bytes"]=>
# int(436)
# ["seekable"]=>
# bool(true)
# ["uri"]=>
# string(15) "sample_text.txt"
var_dump(ftell($fp));
#int(147)
$res = fgets($fp);
var_dump($res);
var_dump(stream_get_meta_data($fp));
var_dump(ftell($fp));
#int(364)
rewind($fp);
var_dump(ftell($fp));
#先頭に戻す
#int(0)
$res = fgets($fp);
#先頭に戻っている
var_dump($res);
You can’t perform that action at this time.