<?php $ctx = stream_context_create( array( 'http' => array( 'timeout' => 1 //设置一个超时时间,单位为秒 ) ) ); file_get_contents("http://example.com/", 0, $ctx); ?>
file_get_contents 超时设置
现主要从事PHP、Uinx/Linux、C/C++等方面的项目开发。
<?php $ctx = stream_context_create( array( 'http' => array( 'timeout' => 1 //设置一个超时时间,单位为秒 ) ) ); file_get_contents("http://example.com/", 0, $ctx); ?>