PHP Curl Function Error: Call to Undefined Function Solved
Your PHP code is encountering a fatal error due to the unavailability of the curl_init() function. This function is a part of the PHP CURL (Client URL Library) extension, which must be installed and enabled for your PHP installation.
Solution:
To resolve this issue, follow these steps:
- Install PHP CURL extension:
-
Ubuntu: sudo apt-get install php5-curl
-
Other distributions: Refer to your package management tools for the appropriate command.
- Restart Apache server:
- sudo /etc/init.d/apache2 restart
- Verify installation:
- Use phpinfo() to confirm that CURL is listed as installed.
Additional Tips:
- If you continue to experience issues, ensure that the PHP CURL extension is enabled in your PHP configuration (e.g., php.ini).
- Consult the PHP CURL documentation for detailed installation instructions: [https://www.php.net/manual/en/book.curl.php](https://www.php.net/manual/en/book.curl.php)
The above is the detailed content of Why is my PHP code throwing a \'Call to Undefined Function curl_init()\' error?. For more information, please follow other related articles on the PHP Chinese website!