snoopy

PHP Logo

Quickest Way To Download A Web Page With PHP

7th July 2008 - 9 minutes read time

There are lots of different ways to download a web page using PHP, but which is the fastest? In this post I will go through as many different methods of downloading a web page and test them to see which is the quickest.

Here is a list of the different methods.

  • The PHP curl library.
  • Snoopy the PHP web browser. Bascially a wrapper for fsockopen.
  • fsockopen().
  • fopen() with feof().
  • fopen() with stream_get_contents().
  • file() and then implode().
  • file_get_contents() function.

Each method will be run and will retrieve the contents of a web page 50 times each in order to get a decent spread of times. On each run the time will be recorded into an array, this array will then be used at the end to calculate some statistics.