PHP cURL suddenly not loading on Windows 10 Pro

北慕城南 提交于 2020-01-06 06:40:56

问题


A simple php_curl example isn't working anymore on my Windows 10 laptop. It was working before.

Fatal error: Uncaught Error: Call to undefined function curl_init() in C:\Users\path\curl.php:3 Stack trace: #0 {main} thrown in C:\Users\path\curl.php on line 3

My C:\php7\php.ini has extension=C:\php7\ext\php_curl.dll
php_curl.dll exists in C:\php7\ext

PHP Version 7.0.30
Windows 10 Pro Version 1607 Build 14393.2189

But my loclahost/phpinfo.php does not have cURL. How come all of a sudden it disappeared ?

PS : The script worked in the command line. It's just that Apache is not loading the extension.


回答1:


don't know why it suddenly stopped working, but first run <?php phpinfo(~0); , and check which php.ini file that is actually loaded (this avoids editing the wrong php.ini file to no avail) (in this example, it is /etc/php/7.0/fpm/php.ini), then edit that php.ini file, if that file actually has the extension=C:\php7\ext\php_curl.dll line, then some combination of the following settings are set wrong:

display_startup_errors is Off, change it to On

display_errors is Off, change it to On

error_reporting is not E_ALL, change it to error_reporting=E_ALL (and nothing else, not like error_reporting= E_ALL & ~E_NOTICE or whatever, just E_ALL)

html_errors is Off, change it to On

then restart apache, again check the phpinfo() page, and verify that the new configuration options are actually loaded, then run <?php curl_init();, and it should show an error about why the curl extension could not be loaded.




回答2:


I came across some links on other StackOverflow answers (will post the links here if I trace them again). I had Apache 2.4.23 Win64 - I reinstalled Apache to the latest one - 2.4.33 Win64 - and now cURL is working.



来源:https://stackoverflow.com/questions/50365941/php-curl-suddenly-not-loading-on-windows-10-pro

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!