file_get_content不适用于php中的https [英] file_get_content not working for https in php

查看:84
本文介绍了file_get_content不适用于php中的https的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人对https上的网站的显示内容有疑问吗?该代码一直有效,直到服务器上的所有站点都获得ssl.也许是这样的证书是TLS 1.2?因此,尝试从中执行此操作的网站现在已获得此证书.

Has anybody had an issue with display content from a website thats over https? The code was working until all the sites on server got ssl. maybe something to so with the certificate being tlss 1.2? So the site im trying to do this from has this certificate now.

$data = file_get_contents('https://www.ladygaga.com/'); 
echo $data;

推荐答案

根据 php.net

使用SSL时,Microsoft IIS将通过关闭SSL来违反该协议连接,而不发送close_notify指示器.PHP将报告当您到达末尾时,将其显示为"SSL:致命协议错误"数据.要变通解决此问题,error_reporting的值应为降低到不包含警告的水平.PHP可以检测当您使用https://打开流时,有问题的IIS服务器软件包装器,将禁止显示警告.当使用fsockopen()来创建一个ssl://套接字,开发人员负责检测并禁止显示此警告.

When using SSL, Microsoft IIS will violate the protocol by closing the connection without sending a close_notify indicator. PHP will report this as "SSL: Fatal Protocol Error" when you reach the end of the data. To work around this, the value of error_reporting should be lowered to a level that does not include warnings. PHP can detect buggy IIS server software when you open the stream using the https:// wrapper and will suppress the warning. When using fsockopen() to create an ssl:// socket, the developer is responsible for detecting and suppressing this warning.

源链接

这篇关于file_get_content不适用于php中的https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆