note 126406 deleted from function.file-get-contents by cmb
| From: | cmb@php.net | Date: | Thu, 09 Sep 2021 10:06:49 +0000 |
| Subject: | note 126406 deleted from function.file-get-contents by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-216937@lists.php.net to get a copy of this message | ||
Note Submitter: 453034559 at qq dot com
----
//è·å仿å®ä½ç½®å°æå®ä½ç½®çæä»¶å
容
function file_start_end($path,$start=0,$end=null){
if(!file_exists($path)) return false;
$size=filesize($path);
if(abs($start)>$size){
//å¼å§ä½ç½®ç»å¯¹å¼ä¸è½è¶
è¿æä»¶å¤§å°
return false;
}
if($start<0) $start+=$size;
if($end===null) {//é»è®¤å°æå
$end=$size;
}elseif ($end<0) {//å ä¸<=0 ä¹å¯ä»¥ ä¸å¥½çè§£
$end+=$size;
}
if(abs($end)>$size){
//ç»æä½ç½®ç»å¯¹å¼ä¸è½è¶
è¿æä»¶å¤§å°
return false;
}
$length=$end-$start;
if($length<1) {
return false;
}
return file_get_contents($path, false, null, $start, $length );
}