php tutorial fread function and fread function usage / * fread syntax: string fread (resource $ handle, int $ length)
The length of the byte read by fread () is handled by the file pointer referenced. Read as soon as possible to one of the following conditions:
The byte length that has been read ! eof (end of file) reaches a package of available networks (streams) 8192 bytes have been read (user space flow opened)
* /
// fread read the file instance one
$ filename = "/www.jzread.com/local/something.txt"; $ handle = fopen ($ filename, "r"); $ contents = fread ($ handle, filesize ($ filename)); fclose ($ handle); // php5 or later reads the contents of the remote server
$ handle = fopen ("http://down.jzread.com/", "rb"); $ contents = ''; while (! feof ($ handle)) { $ contents. = fread ($ handle, 8192); } fclose ($ handle); / * Sometimes the purpose of streaming is not marked with eof, nor is it a fixed sign, which is why this loop forever. This caused me a lot of trouble ... I solved it using the stream_get_meta_data function as shown below with a break statement:
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.