方法一:
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模块测试。
如果不方便修改服务器配置,可以参考使用如下的函数来解决:
代码示例:
1
2
3
4
5
6
7
8
9
10
11
12
|
<?php
//file_get_contents抓取https地址内容
function getCurl( $url ){
$ch = curl_init();
curl_setopt( $ch , CURLOPT_URL, $url );
curl_setopt( $ch , CURLOPT_RETURNTRANSFER,1);
curl_setopt( $ch , CURLOPT_SSL_VERIFYPEER, false);
curl_setopt( $ch , CURLOPT_SSL_VERIFYHOST, false);
$result = curl_exec( $ch );
curl_close ( $ch );
return $result ;
}
|
方法二:
在php中,利用https://www.kuaiidc.com/tag/file_get_contents" title="file_get_contents">file_get_contents函数抓取url是https开头的网站网页内容时,会出现类似下面的错误警告:
Warning: https://www.kuaiidc.com/tag/file_get_contents" title="file_get_contents">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中https://www.kuaiidc.com/tag/file_get_contents" title="file_get_contents">file_get_contents函数抓取https地址出错,希望对大家有所帮助。
相关文章
- ASP.NET本地开发时常见的配置错误及解决方法? 2025-06-10
- ASP.NET自助建站系统的数据库备份与恢复操作指南 2025-06-10
- 个人网站服务器域名解析设置指南:从购买到绑定全流程 2025-06-10
- 个人网站搭建:如何挑选具有弹性扩展能力的服务器? 2025-06-10
- 个人服务器网站搭建:如何选择适合自己的建站程序或框架? 2025-06-10
- 2025-07-10 怎样使用阿里云的安全工具进行服务器漏洞扫描和修复?
- 2025-07-10 怎样使用命令行工具优化Linux云服务器的Ping性能?
- 2025-07-10 怎样使用Xshell连接华为云服务器,实现高效远程管理?
- 2025-07-10 怎样利用云服务器D盘搭建稳定、高效的网站托管环境?
- 2025-07-10 怎样使用阿里云的安全组功能来增强服务器防火墙的安全性?
快网idc优惠网
QQ交流群
-
如何利用Shopyy的功能进行有效的客户关系管理(CRM)?
2025-05-27 76 -
Linux使用libnet实现ARP攻击脚本原理分析以防被攻击
2025-05-27 62 -
2025-05-25 78
-
2025-05-25 94
-
2025-05-25 48