fgets() and fread() - What is the difference?

前端 未结 5 1582
旧巷少年郎
旧巷少年郎 2021-02-03 21:03

I understand the differences between fgets() and fgetss() but I don\'t get the difference between fgets() and fread()<

5条回答
  •  孤城傲影
    2021-02-03 21:05

    Both the functions are used to read data from files

    fgets($filename, $bytes) fgets usually reads $bytes-1 amount of data and stops at a newline or an EOF(end-of-file) whichever comes first. If the bytes are not specified, then the default value is 1024 bytes.

    fread($filename, $bytes) fread reads exactly $bytes amount of data and stops only at EOF.

提交回复
热议问题