Fetching files form PHP in a compatible way


I just finished comparing a whole bunch of OS’s to determine which is the most compatible (widely available) way to fetch an external HTTP page from PHP. The winner is:

fsockopen – it was available on 100% of the tested systems. I was only interested in HTTP pages, not HTTPS, so the ssl transport might not be as widely available. One sidenote: it is interesting that many people disable “allow_url_fopen”, but leave fsockopen in, even though in many cases they are one and the same thing…

Debian 4.0 CentOS 5.2 Ubuntu Server 8.04 LTS Gentoo 2008.0 IIS4 + PHP 5.2 OpenSUSE 11.0 FreeBSD 7.0 OpenBSD 4.4** WinXP + Apache 2.2 + PHP 5.2 WinXP + XAMPP 1.6.8 Slackware 12.1*
cURL installed 0 1 0 0 0 1 0 0 0 0 1 27%
wget installed 1 1 0 1 0 1 0 0 0 0 1 45%
php_curl installed 0 1 0 0 0 0 1 0 0 1 1 36%
php_curl enabled 0 1 0 0 0 0 0 0 0 0 1 18%
sockets installed 1 1 1 1 1 1 1 1 1 1 1 100%
sockets enabled 1 1 1 1 1 1 1 1 1 1 1 100%
url_fopen enabled 1 1 1 0 1 1 1 0 1 1 1 82%

Notes:

*mod_php is not enabled by default
** php installed with pkg_add php5-core


Leave a Reply

Your email address will not be published. Required fields are marked *