file_get_content() 超时

set_time_limit 只能影响php 程序的超时时间。
file_get_contents 读取的是URL的超时时间。
 
因此 set_limit_limit 对file_get_contents 是无效的。
 
<?php

$opt =array(
    'http'=>array(
        'method'=>'GET',
        'timeout'=>60,
        )
    );

$context =stream_context_create($opt);

$html=file_get_contents('http://www.baidu.com',false,$context);

fpassthru($fp);
原文地址:https://www.cnblogs.com/yhl664123701/p/4103735.html