|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2012-08-08 02:47 UTC] aharvey@php.net
-Status: Open
+Status: Not a bug
[2012-08-08 02:47 UTC] aharvey@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 16:00:01 2025 UTC |
Description: ------------ fgets() does not load the binary data for unpack to process. If the fgets() function is replaced with fread() then the example below works as expected. The current documentation claims that fgets() is binary safe, which appears to be incorrect. Test script: --------------- <?php print "Saving...\n"; $F=fopen('1.evid','wb'); fwrite($F,pack('C6',65,66,67,68,69,70)); fclose($F); print "Loading...\n"; $F=fopen('1.evid','rb'); $d=unpack('C6',fgets($F,6)); print "Result: ".print_r($d,1)."\n"; print count($d)."\n"; fclose($F); Expected result: ---------------- It should display an array with 6 values, as written to the file. Actual result: -------------- No data is read, the array is empty.