Home > php教程 > php手册 > body text

PHP中file_get_contents函数抓取https地址出错的解决方法(两种方法)

WBOY
Release: 2016-06-06 19:44:18
Original
1471 people have browsed it

本文通过两种方法解决PHP中file_get_contents函数抓取https地址出错,需要的朋友可以参考下

方法一:

在php中,抓取https的网站,,提示如下的错误内容:

Warning: file_get_contents() [function.file-get-contents]: failed to open stream: Invalid argument in I:Webmyphpa.php on line 16

打开php.ini文件找到 ;extension=php_openssl.dll ,去掉双引号”;” ,重启web服务器即可。

apache服务器的话,可以同时启用mod_ssl模块测试。

如果不方便修改服务器配置,可以参考使用如下的函数来解决:

代码示例:

方法二:

在php中,利用file_get_contents函数抓取url是https开头的网站网页内容时,会出现类似下面的错误警告:

Warning: file_get_contents(https://127.0.0.1/index.php) [function.file-get-contents]: failed to open stream: Invalid argument in E:\website\blog\test.php on line 25

打开php.ini找到 ;extension=php_openssl.dll ,去掉双引号”;” ,重启web服务器即可。

apache的可以同时启用mod_ssl模块测试

以上内容给大家分享了两种方法解决PHP中file_get_contents函数抓取https地址出错,希望对大家有所帮助。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact [email protected]
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!