note 129086 added to function.stream-get-contents

From: Date: Mon, 04 Dec 2023 02:45:11 +0000
Subject: note 129086 added to function.stream-get-contents
Groups: php.notes 
Request: Send a blank email to php-notes+get-221040@lists.php.net to get a copy of this message
It states that $length parameter which value is null is intended to read all remaining contents from $stream However, example listed under docs uses -1 as $length parameter to achieve such behavior Recently i had to start few commands from php7.4 and read content from them, proc_open was used to create processes. Both output[1] and error[2] pipes were set to non-blocking mode. For some unknown reason sometimes process error[2] channel was available, sometimes not(it was empty string). After some investigation it was found that stream_get_contents works just great with -1 as a $length value instead of null if you are trying to get all remaining buffer. ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.157.134 (proxied: 185.90.102.86) ---- Manual Page -- https://php.net/manual/en/function.stream-get-contents.php Edit -- https://main.php.net/note/edit/129086 Del: integrated -- https://main.php.net/note/delete/129086/integrated Del: useless -- https://main.php.net/note/delete/129086/useless Del: bad code -- https://main.php.net/note/delete/129086/bad+code Del: spam -- https://main.php.net/note/delete/129086/spam Del: non-english -- https://main.php.net/note/delete/129086/non-english Del: in docs -- https://main.php.net/note/delete/129086/in+docs Del: other reasons-- https://main.php.net/note/delete/129086 Reject -- https://main.php.net/note/reject/129086 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#221040) next »