Home > Backend Development > PHP Tutorial > fread 和fgets选择?

fread 和fgets选择?

WBOY
Release: 2016-06-23 14:15:11
Original
1234 people have browsed it

区别基本清楚,现在是实际开发中应该如何选择呢?


回复讨论(解决方案)

那就要看你的业务需求了,一个是一行一行读,一个是你自己设定要读取的块大小。
怎么说呢,一般大部分需求都是一行一行度,比如读一个配置信息的文件或者其他,因此大部分都是一行一行读。fgets也是php默认选择的方法

很明显,如果需要按照按行读取的话,肯定是fgets,否则你肯定不是按行读取,不按行读取要么是按照块读取fread或者全文件读取file_get_contents

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template