Home  >  Article  >  Backend Development  >  How to Fix the PHP Fatal Error: Call to undefined function curl_init()?

How to Fix the PHP Fatal Error: Call to undefined function curl_init()?

Susan Sarandon
Susan SarandonOriginal
2024-11-27 00:53:09197browse

How to Fix the PHP Fatal Error: Call to undefined function curl_init()?

PHP Fatal Error: Undefined Function curl_init()

To resolve the "Call to undefined function curl_init()" error in PHP, the cURL extension must be installed and enabled.

cURL Installation and Activation

Ubuntu:

sudo apt-get install php5-curl

Other Systems:

Install cURL using your package manager or follow the instructions in the PHP cURL documentation (https://www.php.net/manual/en/book.curl.php).

Restart Apache

Restart your web server to load the cURL extension:

Apache:

sudo /etc/init.d/apache2 restart

Nginx:

sudo systemctl restart nginx

Verifying Installation

Use phpinfo() to confirm that cURL is installed and enabled:

<?php
phpinfo();
?>

If cURL is installed correctly, you should see the "cURL" section in the output.

Additional Information

  • If you continue to encounter issues, check the PHP configuration file (php.ini) to ensure that the cURL extension is uncommented.
  • You can also try using the curl_version() function to verify the cURL version installed on your system.

The above is the detailed content of How to Fix the PHP Fatal Error: Call to undefined function curl_init()?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn