<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head><meta forua="true" http-equiv="Cache-Control" content="max-age=0" /></head>
<card title="解决PHP中file_get_contents函数抓取https地址出错的两种方法" id="card1">
<p> 游客</p><p>
标题:解决PHP中file_get_contents函数抓取https地址出错的两种方法<br/>
正文:<br/>
方法一：在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模块测试。如果不方便修改服务器配置，可以参考使用如下的函数来解决：代码示例:&amp;lt;?php<br/>//file_get_contents抓取https地址内容<br/>function getCurl($url){<br/>$ch = curl_init();<br/>curl_setopt($ch, CURLOPT_URL,$url);<br/>curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);<br/>curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);<br/>curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);<br/>$result = curl_exec($ch);<br/>curl_close ($ch);<br/>return $result;<br/>}方法二：在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模块测试<br/><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2226&amp;Page=1">[&lt;&lt;]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2226&amp;Page=1">[[1]]</a><a href="http://camnpr.com/wap.asp?mode=WAP&amp;act=View&amp;id=2226&amp;Page=1">[&gt;&gt;]</a><br/>
<br/>
<a href="wap.asp?act=Com&amp;id=2226">查看评论(0)</a><br/>
<a href="wap.asp?act=AddCom&amp;inpId=2226">发表评论</a><br/><br/>

<br/>

<br/>
<a href="http://camnpr.com/wap.asp">首页</a>
</p>
</card>
</wml>