note 108013 added to function.stream-get-contents
| From: | vasiliy at hotger dot com | Date: | Thu, 22 Mar 2012 08:38:02 +0000 |
| Subject: | note 108013 added to function.stream-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-186769@lists.php.net to get a copy of this message | ||
It is important to know that stream_get_contents behaves differently with different versions of PHP.
Consider the following
<?php
$handle = fopen('file', 'w+'); // truncate + attempt to create
fwrite($handle, '12345'); // file position > 0
rewind($handle); // position = 0
$content = stream_get_contents($handle); // file position = 0 in PHP 5.1.6, file position > 0 in
PHP 5.2.17!
fwrite($handle, '6789');
fclose($handle);
/**
*
* 'file' content
*
* PHP 5.1.6:
* 67895
*
* PHP 5.2.17:
* 123456789
*
*/
?>
As a result, stream_get_contents() affects file position in 5.1, and do not affect file position in
5.2 or better.
----
Server IP: 69.147.83.197
Probable Submitter: 195.208.247.26
----
Manual Page -- http://www.php.net/manual/en/function.stream-get-contents.php
Edit -- https://master.php.net/note/edit/108013
Del: integrated -- https://master.php.net/note/delete/108013/integrated
Del: useless -- https://master.php.net/note/delete/108013/useless
Del: bad code -- https://master.php.net/note/delete/108013/bad+code
Del: spam -- https://master.php.net/note/delete/108013/spam
Del: non-english -- https://master.php.net/note/delete/108013/non-english
Del: in docs -- https://master.php.net/note/delete/108013/in+docs
Del: other reasons-- https://master.php.net/note/delete/108013
Reject -- https://master.php.net/note/reject/108013
Search -- https://master.php.net/manage/user-notes.php