Home >Backend Development >PHP Tutorial >Efficiency analysis of classic methods for capturing network data (fsockopen/curl/file_get_contents) filegetcontents timeout js file get contents filegetcontents

Efficiency analysis of classic methods for capturing network data (fsockopen/curl/file_get_contents) filegetcontents timeout js file get contents filegetcontents

WBOY
WBOYOriginal
2016-07-29 08:53:391269browse
fsocketopen/curl/file_get_contents comparison
fsocketopen is a relatively low-level call, which belongs to the socket call of the network system

1. fsockopen returns unprocessed data, including data Length data content and data terminator

2. You can set the interaction based on UDP or TCP protocol

curl

The packaging of curl supports HTTPS authentication, HTTP POST/ PUT method, cookies, etc. are very powerful.

1. curl returns the processed content

2. Automatically caches DNS query information. The same domain name is only queried once, which has higher performance and efficiency

3. Supports get and post. Method request

fopen/file_get_contents

Each request will re-do the DNS query and does not cache the DNS information.

is using http_fopen_wrapper and does not keeplive.

1. Low efficiency

2. Data can only be obtained through get

The above introduces the efficiency analysis of the classic method of capturing network data (fsockopen/curl/file_get_contents), including the content of file_get_contents. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
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