#28517 [Ver->Bgs]: differing behaviour between sscanf/ffscanf
ID: 28517
Updated by: sniper@php.net
Reported By: dolfi at zkm dot de
-Status: Verified
+Status: Bogus
Bug Type: Strings related
Operating System: *
-PHP Version: 4CVS, 5CVS (2004-12-12)
+PHP Version: 4.3.9
New Comment:
It's because they're totally different functions.
fsscanf() reads file from descriptor. Your example only reads first
line from the file, that being the \n char..
Previous Comments:
------------------------------------------------------------------------
[2004-05-25 18:03:02] dolfi at zkm dot de
Description:
------------
fscanf on multiline input works differently than sscanf on exactly the
same data presented as a string.
Reproduce code:
---------------
<pre>
<?php
$str = "\n bla \nblup"; $file = "test.txt";
$fd = fopen($file, 'w'); fputs($fd, $str);
fclose($fd);
list($a,$b) = sscanf($str, ' %[a-z] %[a-z] ');
echo "$a;$b;\n";
$fd = fopen($file, 'r');
list($a,$b) = fscanf($fd, ' %[a-z] %[a-z] ');
fclose($fd);
echo "$a;$b;\n";
?>
</pre>
Expected result:
----------------
bla;blup;
bla;blup;
Actual result:
--------------
bla;blup;
;;
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=28517&edit=1
Thread (3 messages)