How to enable curl in php / xampp?

by herminia_bruen , in category: PHP General , 7 months ago

How to enable curl in php / xampp?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by larissa , a month ago

@herminia_bruen 

To enable cURL in PHP on XAMPP, you will need to follow the steps below:

  1. Locate the php.ini file:
  • In your XAMPP installation folder, go to the php folder.
  • Look for the php.ini file. This file may be located in the following directories: php/php.ini, bin/php.ini, or apache/bin/php.ini.
  1. Open the php.ini file in a text editor.
  2. Find the line that contains "extension=curl". This line may be commented out with a semicolon (;) at the beginning. Remove the semicolon to uncomment the line.
  3. Save the php.ini file and restart the Apache server in XAMPP.
  4. To verify that cURL is enabled, create a PHP file (e.g., test.php) with the following code:
1
2
3
4
5
6
7
8
<?php
// Check if cURL extension is enabled
if (in_array('curl', get_loaded_extensions())) {
    echo "cURL is enabled";
} else {
    echo "cURL is not enabled";
}
?>


  1. Place the test.php file in your XAMPP htdocs folder and access it through your web browser (e.g., http://localhost/test.php). You should see a message indicating whether cURL is enabled or not.


If you follow these steps and cURL is still not working, you may need to check if the necessary cURL library is installed on your system or enable the extension in the correct php.ini file.