Ace*_*dan 5 php curl php-7 ubuntu-16.04
我已经完成了 sudo apt-get install curl、sudo apt-get php5-curl、sudo apt-get php-curl 但我得到了 curl_init() 的未定义函数
有没有人知道任何解决方案?
这是我的 PHP 代码。
<?php
// create curl resource
$ch = curl_init();
// set url
curl_setopt($ch, CURLOPT_URL, "example.com");
//return the transfer as a string
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $output contains the output string
$output = curl_exec($ch);
// close curl resource to free up system resources
curl_close($ch);
?>
Run Code Online (Sandbox Code Playgroud)
检查apache使用的PHP版本,通过使用phpinfo();函数。
检查很重要,因为您可能出于任何原因切换到较低版本(就像我的情况一样)。
现在从命令行运行此命令来安装curl
*(Don\'t copy this) sudo apt-get install php[version of php]-curl*
Run Code Online (Sandbox Code Playgroud)
例如,如果是5.6,则使用
sudo apt-get install php5.6-curl
Run Code Online (Sandbox Code Playgroud)
之后,不要忘记重新启动apache2
sudo service apache2 restart
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
15461 次 |
| 最近记录: |