(PHP 5, PHP 7, PHP 8)
stream_get_contents — 读取资源流到一个字符串
   与 file_get_contents() 一样,但是
    stream_get_contents() 是对一个已经打开的资源流进行操作,并将其内容写入一个字符串返回。
   返回的内容取决于 length 字节长度和 offset 指定的起始位置。
  
   返回一个字符串  或者在失败时返回 false.
  
| 版本 | 说明 | 
|---|---|
| 8.0.0 | 
       现在 length 可以为 null。
       | 
     
示例 #1 stream_get_contents() 例子
<?php
if ($stream = fopen('http://www.example.com', 'r')) {
    // 打印从开始的位置偏移 10 个字节后页面的所有内容
    echo stream_get_contents($stream, -1, 10);
    fclose($stream);
}
if ($stream = fopen('http://www.example.net', 'r')) {
    // 打印前 5 个字节
    echo stream_get_contents($stream, 5);
    fclose($stream);
}
?>