<?

        $fp = fopen("test.txt","r");

        if(!$fp) {

                echo "file read fail";

                exit;

        }

        while(!feof($fp)) {

                echo fgets($fp,10000),"\n";

        }


        rewind($fp);

        echo fgets($fp,10000),"\n";


        fseek($fp,10,SEEK_SET);

        echo fgets($fp,10000),"\n";


        fseek($fp,5,SEEK_CUR);

        echo fgets($fp,10000),"\n";


        fseek($fp,5,SEEK_END);

        echo fgets($fp,10000),"\n";

?>





output)


My name is byoungguk kim.


I'm fine thank you.


hello hello hello



My name is byoungguk kim.


 byoungguk kim.


ine thank you.





SEEK_SET
Position file relative to the beginning.
SEEK_CUR
Position file relative to the current position.
SEEK_END

Position file relative to the end.



신고
크리에이티브 커먼즈 라이선스
Creative Commons License

WRITTEN BY
김병국
유용했던 자료를 기록해 두었습니다. 도움이 되시길~~~ Welcome! I started this blog as a way to give back to all of the other system administrators who have taught me something in the past. Writing these posts brings me a lot of enjoyment and I hope you fun

받은 트랙백이 없고 , 댓글이 없습니다.
secret