(PHP 5, PHP 7)
stream_get_contents — 锟斤拷取锟斤拷源锟斤拷锟斤拷一锟斤拷锟街凤拷锟斤拷
$handle
[, int $maxlength
= -1
[, int $offset
= -1
]] ) : string
锟斤拷 file_get_contents() 一锟斤拷锟斤拷锟斤拷锟斤拷
stream_get_contents() 锟角讹拷一锟斤拷锟窖撅拷锟津开碉拷锟斤拷源锟斤拷锟斤拷锟叫诧拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷写锟斤拷一锟斤拷锟街凤拷锟斤拷锟斤拷锟截★拷
锟斤拷锟截碉拷锟斤拷锟斤拷取锟斤拷锟斤拷 maxlength
锟街节筹拷锟饺猴拷 offset
指锟斤拷锟斤拷锟斤拷始位锟矫★拷
锟斤拷锟斤拷一锟斤拷锟街凤拷锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
.
锟芥本 | 说锟斤拷 |
---|---|
5.1.0 |
锟斤拷锟接诧拷锟斤拷 offset 锟斤拷
|
Example #1 stream_get_contents() 锟斤拷锟斤拷
<?php
if ($stream = fopen('http://www.example.com', 'r')) {
// print all the page starting at the offset 10
echo stream_get_contents($stream, -1, 10);
fclose($stream);
}
if ($stream = fopen('http://www.example.net', 'r')) {
// print the first 5 bytes
echo stream_get_contents($stream, 5);
fclose($stream);
}
?>
Note: 锟剿猴拷锟斤拷锟缴帮拷全锟斤拷锟节讹拷锟斤拷锟狡讹拷锟斤拷