PHP下fopen无法打开https链接的解决方法

2015-02-11 14:26:20    2015-02-11 14:27:08

症状

在PHP中尝试用fopen()函数打开一个https的链接,结果运行时发现以下错误

fopen(): Unable to find the wrapper "https" - did you forget to enable it when you configured PHP?

原因和解决方法

原因是php.ini配置文件中没有设定好,需要更改以下两项(如果不存在的话需要添加)

extension=php_openssl.dll  //这一项默认可能是注释掉的,要把最前面的注释分号去掉
allow_url_include = On  //这项默认是Off,需要改成On

再重启Web Server就可以了