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
(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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.