PHP 5.2.14 cURL not working on Windows
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:
- You have uncommented the right line in your
- You have a
php_curl.dllin your PHP extensions folder.
- You have the PHP installation directory in your Windows
- You have checked your phpinfo(); (see below for instructions) and can’t see an entry for cURL listed there.
- You have restarted your Apache (or other webserver) and re-checked your
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:
If it’s not there, you can run the following PHP script:
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.
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 22.214.171.124 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
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();
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.