简体   繁体   中英

Enabling the cURL library for PHP using XAMPP for Windows

I am running PHP code with the following code invovled:

$ch = curl_init();

When I get to this line, the following error is returned:

Fatal error: Call to undefined function curl_init() in C:\\xampp\\htdocs\\myfiles\\API\\IPVIKING_API.php on line 79

Now I've found all the answers talking about enabling the curl extension in the php.ini file, and I've done that, following this question here: How to enable curl in xampp? .

My problem is I do not have these 3 files:

C:\Program Files\xampp\apache\bin\php.ini
C:\Program Files\xampp\php\php.ini
C:\Program Files\xampp\php\php4\php.ini

I instead have 2 files called

C:\Program Files\xampp\php\php.ini-development
C:\Program Files\xampp\php\php.ini-production

I've uncommented the

;extension=php_curl.dll

line in both of them, restarted both my browser and xampp, yet it still gives me the same error. Suggestions?

Make an

<?php phpinfo(); ?>

there you can see which php.ini is loaded. In this file you uncomment the the extension line.

When there is no php.ini in this path which is in the phpinfo this should be xampp/php/php.ini then rename one of the two files

C:\Program Files\xampp\php\php.ini-development

to

C:\Program Files\xampp\php\php.ini

You should move C:\\Program Files\\xampp\\php\\php.ini-production to C:\\Program Files\\xampp\\php\\php.ini.

rename "C:\Program Files\xampp\php\php.ini-production" "C:\Program Files\xampp\php\php.ini"

And then change:

;extension=php_curl.dll

to

extension=php_curl.dll

Then restart Apache.

Some systems require two files to be copied from where PHP is installed to your WINDOWS\\System32 directory:

libeay32.dll
ssleay32.dll

Update:

copy "C:\Program Files\xampp\php\php.ini" "C:\xampp\php\php.ini"

search for 'php.ini' file in

xampp\\php\\ directory

open php.ini

find for 'curl'

you will get line

;extension=php_curl.dll

uncomment it by removing semicolon at front of the line

extension=php_curl.dll

There is a file named php (I think this is the real php.ini) with the type as configuration settings that is the one you need to uncomment extension = php_curl.dll. You should also uncomment the .ini-development and .ini-production . Restart and both browser and apache and it should work.

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