file_get_contents 获取httpCode

<div>&nbsp; &nbsp; &nbsp; &nbsp; $opts = array(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "http" =&gt; array(</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "method" =&gt; "GET",</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "timeout" =&gt; 10,</div><div>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; )</div><div>&nbsp; &nbsp; &nbsp; &nbsp; );</div><div>&nbsp; &nbsp; &nbsp; &nbsp; $result_json = file_get_contents("http://api.phpnuts.com/result/power/3", false, stream_context_create($opts));</div><div><br></div><div>&nbsp; &nbsp; &nbsp; &nbsp; echo substr($http_response_header[0], 9, 3);</div>

评论