|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28517 differing behaviour between sscanf/ffscanf
Submitted: 2004-05-25 18:03 UTC Modified: 2004-12-15 09:42 UTC
From: dolfi at zkm dot de Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.9 OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: dolfi at zkm dot de
New email:
PHP Version: OS:


 [2004-05-25 18:03 UTC] dolfi at zkm dot de
fscanf on multiline input works differently than sscanf on exactly the same data presented as a string.

Reproduce code:
$str = "\n bla \nblup"; $file = "test.txt";
$fd = fopen($file, 'w'); fputs($fd, $str);
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] ');
echo "$a;$b;\n";

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-12-15 09:42 UTC]
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..

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Feb 23 21:01:28 2024 UTC