note 126406 deleted from function.file-get-contents by cmb

From: 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 ); }

« previous php.notes (#216937) next »