Three functions, although they are all functions that read resources, differ in their application scenarios.
Curl is used for crawling between Web pages, fopen is used to read files, and file_get_contents is used to get static page content more.
1. Fopen/file_get_contents each request will redo the DNS query, does not cache DNS information. However, Curl will automatically cache DNS information. Requests for a Web page or picture under the same domain name require only a single DNS query. This greatly reduces the number of DNS queries. So curl performance is much better than fopen/file_get_contents.
2. When requesting HTTP, the fopen/file_get_contents uses Http_fopen_wrapper and does not keeplive. and curl can. This makes curl more efficient when multiple links are requested more than once.
3. Curl can simulate a variety of requests, such as post data, form submission, etc., users can customize the request according to their own needs. Fopen/file_get_contents can only obtain data using GET.