Beware this content is over 8 years old and considered stale. It may no longer be accurate and/or reflect the understanding of the author but remains here for reference only. Please keep this in mind as you use this content.

If you are trying to enable cURL on Windows XP (running Apache or not) or you get an error message something to the effect of Call to undefined function: curl_init(), you may have come across a problem where you can’t enable the cURL extension despite the fact:

  1. You have uncommented the right line in your php.ini file.
  2. You have a php_curl.dll in your PHP extensions folder.
  3. You have the PHP installation directory in your Windows PATH.
  4. You have checked your phpinfo(); (see below for instructions) and can’t see an entry for cURL listed there.
  5. You have restarted your Apache (or other webserver) and re-checked your phpinfo();

According to the PHP Bug report #52452 the situation is closed but I still don’t see an updated installation binary available for download. At the time of writing the downloads for PHP 5.2.14 are dated, 2010-Jul-27 10:50:52.

So how do you solve the problem and how do you get cURL enabled for PHP 5.2.14?

For now, you’ll have to replace the broken DLL with one from a previous version of PHP. I have tested this with the second most recent release of PHP 5.2.x, PHP 5.2.13.

To check which version of the PHP cURL DLL you have installed find the file in the PHP extension folder.

If you can’t find the PHP extension folder which for many Windows users can be found at:

C:\Program Files\PHP\ext

If it’s not there, you can run the following PHP script:

<?php phpinfo(); ?>

It should display all configuration settings for your installed version of PHP (which should be PHP 5.2.14). Look for the entry extension_dir to find out where PHP is looking for extensions.

Running the phpinfo() script will also be the best way to tell if the cURL extension is indeed working or running.

Once you’ve found your PHP extension directory find the php_curl.dll, right-click the file and select ‘Properties’ and click on the ‘Version’ tab. It should display the file version as if your running PHP 5.2.14, that’s the broken DLL.

You can either download the zip for PHP 5.2.13 and extract the php_curl.dll yourself or you can download it from here.

Just remember to rename your original/broken php_curl.dll to something sensible (e.g. php_curl.dll.orig) for safe keeping and then paste this file in it’s place and rename it to php_curl.dll

Needless to say, I used this file and it works for me but YMMV so I’m providing it with no gurantees at all. By downloading it you agree to not blame me if anything goes wrong. Make sure you test it.

Once your done, check your phpinfo() script or run the test script below:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, '');
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10)
$data = curl_exec($ch);


You should see some output from the URL as the header information is returned.

Hope the above helps, if you get stuck be sure to drop a comment below.