Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.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 获取一条长流的子流_Php_String_Stream_File Get Contents_Substr - Fatal编程技术网

Php 获取一条长流的子流

Php 获取一条长流的子流,php,string,stream,file-get-contents,substr,Php,String,Stream,File Get Contents,Substr,我只想读取一些长流开头的一些有限字符,但是file\u get\u contents不支持seek操作,我必须首先读取整个流,以使用substr提取字符串的所需部分 由于我的资源有限,而且应用程序的速度非常重要,我如何才能更有效地实现这一点?根据您的配置,我可以做到这一点。从该页上的示例中: $handle = fopen("http://www.example.com/", "r"); 然后,您可以使用读取所需的字节数,然后只读取它。具体是什么流?可以吗?@minitech以URL为例。我的

我只想读取一些长流开头的一些有限字符,但是
file\u get\u contents
不支持seek操作,我必须首先读取整个流,以使用
substr
提取字符串的所需部分


由于我的资源有限,而且应用程序的速度非常重要,我如何才能更有效地实现这一点?

根据您的配置,我可以做到这一点。从该页上的示例中:

$handle = fopen("http://www.example.com/", "r");

然后,您可以使用读取所需的字节数,然后只读取它。

具体是什么流?可以吗?@minitech以URL为例。我的应用程序现在的速度是10倍