note 126406 added to function.file-get-contents

From: Date: Thu, 09 Sep 2021 07:45:19 +0000
Subject: note 126406 added to function.file-get-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-216935@lists.php.net to get a copy of this message
//获取从指定位置到指定位置的文件内容 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 ); } ---- Server IP: 45.112.84.4 Probable Submitter: 45.112.85.242 (proxied: 125.70.31.224) ---- Manual Page -- https://php.net/manual/en/function.file-get-contents.php Edit -- https://main.php.net/note/edit/126406 Del: integrated -- https://main.php.net/note/delete/126406/integrated Del: useless -- https://main.php.net/note/delete/126406/useless Del: bad code -- https://main.php.net/note/delete/126406/bad+code Del: spam -- https://main.php.net/note/delete/126406/spam Del: non-english -- https://main.php.net/note/delete/126406/non-english Del: in docs -- https://main.php.net/note/delete/126406/in+docs Del: other reasons-- https://main.php.net/note/delete/126406 Reject -- https://main.php.net/note/reject/126406 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#216935) next »