Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
发生PHP fread捕获流超时_Php_Php Stream Wrappers - Fatal编程技术网

发生PHP fread捕获流超时

发生PHP fread捕获流超时,php,php-stream-wrappers,Php,Php Stream Wrappers,我使用PHP函数fread从使用打开的流中读取数据 $fh=fopen('http://.....'); 我使用 socket_set_timeout($fh,10); 如果在fread执行期间发生超时,那么我是否可以知道这一点 $contents = fread($fh, 1024); 如果发生超时,$内容将等于空字符串还是FALSE?怎么知道超时发生了?有办法吗?根据: 当流超时时,数组的“timed_out”键返回 通过流,尽管未显示任何错误/警告,但将\u get\u meta\u

我使用PHP函数fread从使用打开的流中读取数据

$fh=fopen('http://.....');
我使用

socket_set_timeout($fh,10);
如果在fread执行期间发生超时,那么我是否可以知道这一点

$contents = fread($fh, 1024);
如果发生超时,$内容将等于空字符串还是FALSE?怎么知道超时发生了?有办法吗?

根据:

当流超时时,数组的“timed_out”键返回 通过流,尽管未显示任何错误/警告,但将\u get\u meta\u data()设置为TRUE 生成

因此不会生成错误/警告,但检查
流获取元数据的输出将为您提供线索。

fread()将在发生超时时返回
'
(空字符串),而
套接字读取()
返回
false