file_get_contents默認超時時間(秒)
6 f* ~, |# A; T' i& W( Cphp.ini中的default_socket_timeout設置,默認超時時間是default_socket_timeout = 603 S U9 u1 V J5 f/ w& f: L
$ T1 h( l1 J" Q
如果要修改超時時間,修改第3個參數即可4 q7 M4 S6 x4 O8 v. Q; f
7 k& m- N v2 `- Y v8 J8 a: |$opts = array(" F. o( ]9 h; h
'http'=>array(
5 q* {8 a' k2 w 'method'=>"GET",
6 t$ g1 M, w+ P 'timeout'=>120,: S& p# j' P" `- ^; P
)
$ l+ X% Y" d' b$ y0 Z);( I* c3 S4 [. O5 {
9 ^: I: @. K* g$context = stream_context_create($opts);- A0 F/ ?& M t3 f* i0 h
, d9 b# s+ k. X1 M/ G4 f
$html =file_get_contents('http://www.example.com', false, $context);
4 ]% F" `, D5 ?5 f, [( [ |