php - When does timeout in stream_context_create not work? -



php - When does timeout in stream_context_create not work? -

i'm trying extract little amount of info website finding timing out. i've set coding clauses in place seek , forcefulness code obtain info similar info if trying obtain first takes long.

$ctx = stream_context_create(array('http' => array('timeout' => 2))); $geo = json_decode(file_get_contents($url, 0, $ctx), true);

in principle should time out after 2 seconds , i'll know duff , go sec url. doesn't work, , tries 15 seconds. i've tried recplacing $ctx with

ini_set('default_socket_timeout', 2);

but doesn't work either. can please suggest else try?

there way can set timeout..

it stream_context_create().

$ctx = stream_context_create(array('http'=> array( 'timeout' => 1200, // 1 200 seconds = 20 minutes ) )); echo file_get_contents('the link', false, $ctx);

have here

php

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -