美工统筹SEO,为企业电子商务营销助力!
PHP中file_get_contents函数抓取https地点犯错的处理体例(两种体例)
一佰互联网站开辟设想(www.taishanly.com) 宣布日期 2020-04-27 10:45:00 阅读数: 258
体例一:
在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抓取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中,操纵file_get_contents函数抓取url是https开首的网站网页内容时,会呈现近似上面的毛病正告:
Warning: file_get_contents(http://127.0.0.1/index.php) [function.file-get-contents]: failed to open stream: Invalid argument in E:websitelog est.php on line 25
翻开php.ini找到 ;extension=php_openssl.dll ,去掉双引号”;” ,重启web办事器便可。
apache的能够同时启用mod_ssl模块测试
以上内容给大师分享了两种体例处理PHP中file_get_contents函数抓取https地点犯错,但愿对大师有所赞助。
上一篇: PHP判定字符串长度的两种体例很适用 | 下一篇:浅析PHP关头词替代的类(避免反复替代,保留与复原原始链接)