1.1 Call to undefined function curl_init()
1.1.1 现象
错误信息如下:
Fatal error: Call to undefined function Httpful\curl_init() in D:\ProjectWork\SourceCode\Server\i2goods\protected\vendor\Httpful\Request.php on line
1.1.2 原因
没有开启php_curl扩展。
1.1.3 解决
在PHP.INI中查找“extension=php_curl.dll”,将前面的分号去掉,开启该扩展,然后重启Apache即可。
1.2 Call to undefined function curl_init()
1.2.1 现象
错误信息与上一节一样,按照上一节的解决方案,开启了php_curl扩展后,问题依旧。
1.2.2 原因
查看PHP手册,有如下信息:
Consider whether PHP dir should need to be in $PATH at all, when PHP.exe apparently was found and executes php pages in Apache, but php5apache2_2.dll failed to find whatever was needed to load the extensions. This should perhaps be addressed.
上面这段话,说的是Apache载入的php5apache2_2.dll不知道PHP扩展所在的路径。
1.2.3 解决
将PHP安装路径添加到PATH变量中,重启Apache服务器。
1.3 Call to undefined function curl_init()
1.3.1 现象
运行应用,PHP报错如下:
Fatal error: Call to undefined function Httpful\curl_init() in D:\ProjectWork\SourceCode\Server\i2goods\protected\vendor\Httpful\Request.php on line
注:错误信息与上一节一样,但是按照上一节的方法处理,问题依然存在。
1.3.2 原因
按照6.12节方法开启curl扩展,重启Apache后,问题依然存在,查看Apache的错误日志,报告如下错误:
PHP Warning: PHP Startup: Unable to load dynamic library 'D:/PHPDevEnv/PHP/ext\\php_curl.dll' - The specified module could not be found.\r\n in Unknown on line 0
本机环境为Win7 64位,Apache和PHP也都是64位,用PHP 5.5.9是可以的,但是用PHP 5.6.3就不行,看来是PHP5.6的问题。
1.3.3 解决
在网上找了很久,才找到正解。
将以下文件复制到 apache/bin目录下即可,不需要往 system32 下放任何文件:
libssh2.dll, ssleay32.dll, libeay32.dll
拷贝时如果文件已存在,则略过,一般来说libssh2.dll没有。
将这几个文件拷贝过去后,重启Apache,问题解决。
官方文档:http://cn2.php.net/manual/en/curl.installation.php#115953