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
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.