我在具有PHP 7的Ubuntu 16上安装了cURL,但是仍然无法调用未定义的函数curl_init() [英] I have cURL installed on Ubuntu 16 with PHP 7 but i get still Call to undefined function curl_init()

查看:214
本文介绍了我在具有PHP 7的Ubuntu 16上安装了cURL,但是仍然无法调用未定义的函数curl_init()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经完成了sudo apt-get install curl,sudo apt-get php5-curl,sudo apt-get php-curl,但是我得到了curl_init()的未定义函数

I have done sudo apt-get install curl, sudo apt-get php5-curl, sudo apt-get php-curl but i get undefined function for curl_init()

有人知道对此有什么解决办法吗?

does anyone know any solutions for this?

这是我的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);      
?>

推荐答案

对于运行php7.0的Ubuntu 16.04,您应指定以下版本:

For Ubuntu 16.04 running php7.0, you should specify the version like so:

sudo apt-get install php7.0-curl

然后,像往常一样,使用

Then, as always, restart apache with

sudo service apache2 reload

这篇关于我在具有PHP 7的Ubuntu 16上安装了cURL,但是仍然无法调用未定义的函数curl_init()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆