note 129074 added to function.file-get-contents

From: Date: Wed, 29 Nov 2023 01:58:14 +0000
Subject: note 129074 added to function.file-get-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-221028@lists.php.net to get a copy of this message
If doing a negative offset to grab the end of a file and the file is shorter than the offset, then file_get_contents( ) will return false. If you want it to just return what is available when the file is shorter than the negative offset, you could try again. For example... $contents = file_get_contents( $log_file, false, null, -4096 ); // Get last 4KB if ( false === $contents ) { // Maybe error, or maybe file less than 4KB in size. $contents = file_get_contents( $log_file, false, null ); if ( false === $contents ) { // Handle real error. } } ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 67.0.220.16) ---- Manual Page -- https://php.net/manual/en/function.file-get-contents.php Edit -- https://main.php.net/note/edit/129074 Del: integrated -- https://main.php.net/note/delete/129074/integrated Del: useless -- https://main.php.net/note/delete/129074/useless Del: bad code -- https://main.php.net/note/delete/129074/bad+code Del: spam -- https://main.php.net/note/delete/129074/spam Del: non-english -- https://main.php.net/note/delete/129074/non-english Del: in docs -- https://main.php.net/note/delete/129074/in+docs Del: other reasons-- https://main.php.net/note/delete/129074 Reject -- https://main.php.net/note/reject/129074 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221028) next »