简体   繁体   中英

which is better to get the contents of a web page

To get the contents of a web page which is better: 1) To use Curl 2) file_get_contents 3)Any thing better than the above two.

Thanks for answers in advance

It all boils down to your needs. file_get_contents is a simple and convenient way to get the contents of a webpage, if the HTTP headers it sends are okay for you. However, if you need more complexity, like HTTP authentication or custom headers, cURL will be a better fit.

If you just want to retrieve the contents of a public URL, I'd go for file_get_contents .

1) cURL gives you much much more advanced features about sending cookies, headers, time-to-try, etc and is widely supported on webhosts.

2) On the other hand, file_get_contents is better for quick-jobs (and beginners) when you do not need anything fancy and you are totally sure that it is enabled on the server. Most of the times, it is disabled.

3) There is nothing better than cURL.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM