未捕获的错误:调用未定义的函数curl_init() [英] Uncaught Error: Call to undefined function curl_init()

查看:119
本文介绍了未捕获的错误:调用未定义的函数curl_init()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个wordpress插件正在尝试使用curl,但给了我以下错误。

I have a wordpress plugin that is trying to use curl but giving me the following error.

PHP致命错误:未捕获错误:调用未定义函数curl_init()

PHP Fatal error: Uncaught Error: Call to undefined function curl_init()

$curl = curl_init();

我在本地开发环境和暂存环境中遇到相同的问题。

I have the same issue on my local dev environment and in my staging environment.

http://topmortgagepro.com/whats-your -home-worth /
在发布时将包含phpinfo(),如果以后再看到它,它将被删除。 htaccess的用户名/密码是pixona:pixona,可以看到该网站。

http://topmortgagepro.com/whats-your-home-worth/ At the time of posting it will include the phpinfo() That will be removed if you see this at a later time. htaccess user/password is pixona:pixona to see the site.

我尝试了很多没有运气的解决方案。开放的想法,并可以根据需要显示其他配置设置。

I have tried many solutions offered with no luck. Open to ideas and can show other config settings as needed.

我尝试了以下操作,并且每次重新启动apache后(在本地计算机上):

I have tried the following and restarted apache after each (on local machine):

apt-get install php-curl
apt-get install php7.0-curl

编辑php.ini以取消注释以下内容:

edited the php.ini to uncomment the following:

extension=php_curl.dll
extension=php_bz2.dll

在php中添加了此扩展名。 ini

added this extension in the php.ini

extension=php_curl.so

phpenmod curl


推荐答案

解决方案归结为发行版已过时。为了诊断该问题,我制作了一个示例脚本来查看是否正在加载curl。

The solution came down to the distribution being out of date. To diagnose the issue I made a sample script to see if curl was loading.

<?php
    if (!extension_loaded('curl')) {
        echo 'failed';
    } else {
        echo 'loaded';
    }
?>

这给了我以下错误:

PHP Warning: PHP Startup: Unable to load dynamic library       '/usr/lib/php/20131226/curl.so' - /usr/lib/php/20131226/curl.so: undefined symbol: zend_unset_property in Unknown on line 0

中,因此我遇到了另一个建议这样做的问题

With that I came across this other question which suggested doing

apt-get dist-upgrade

PHP启动:无法加载动态库`curl.so` Ubuntu

升级后(我使用了新的php.ini),脚本运行良好。

After the upgrade (I used the new php.ini) the script worked perfectly.

这篇关于未捕获的错误:调用未定义的函数curl_init()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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