Reputation: 99
I am trying to run a PHP script from the CLI (command line interface) and get this error as if PHP curl is not loaded.
Fatal error: Call to undefined function curl_init()
I have been looking and tried many solutions on here and no results.
What I have done
What does work
Upvotes: 1
Views: 1630
Reputation: 3287
(php 7.4, ubuntu 20.04)
I was getting "Uncaught Error: Call to undefined function" in an unfamiliar library.
I retested with a simple code snippet and got the same error.
<?php
$curl = curl_init();
curl_setopt ($curl, CURLOPT_URL, "http://www.php.net");
curl_exec ($curl);
curl_close ($curl);
?>
I installed php curl
sudo apt-get install php-curl
and retested.
That fixed the problem.
Upvotes: 1