The cURL extension of PHP helps our website to communicate with other websites and APIs with many different types of protocols, including HTTP, HTTPS, FTP, gopher, telnet, dict, file, and ldap protocols. cURL (client URL) is a library created by Daniel Stenberg.
We can also use cURL to perform HTTP form-based upload, proxies, cookies, and user+password authentication.
Error message when cURL is not enabled when WordPress’s AMP plugin is activated.

Or if you use the library’s function such as curl_init(), you will see this error message:
Fatal error: Call to undefined function curl_init()
Steps to enable cURL
In order to use cURL in any PHP applications, we need to enable it in php.ini
file.
- Open php.ini. The location of this file depends on the OS and software you use. For example, it should be C:\xampp\php\php.ini for XAMPP or /etc/php/7.2/apache2/php.ini for Debian Apache. You can pinpoint the exact location by using
phpinfo()
function in a PHP file. - Browse to
;extension=curl
line. - Remove the
;
character before extension to register cURL extension.

- Restart Apache or nginx server.
If cURL is enabled successfully, you will see this part when printing out phpinfo()
.

An example of how to use cURL:
$ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "https://www.google.com"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); echo $output; curl_close($ch);