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
Post a Comment