Re: Documenting sscanf()'s and fscanf's underflow

From: Date: Sun, 24 May 2026 22:55:00 +0000
Subject: Re: Documenting sscanf()'s and fscanf's underflow
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-131007@lists.php.net to get a copy of this message
On 24/05/2026 10:38 pm, mickmackusa wrote:
Hi all, may I request that the documentation pages for sscanf() and fscanf() be reviewed? Last week, I tripped over a bug in my code because, despite using and loving sscanf() for many years, the function unexpectedly returned -1 for the number of successful captures when I expected 0. I've documented the encounter here: https://stackoverflow.com/ q/79942833/2943403 <https://stackoverflow.com/q/79942833/2943403> I have been doing a fair amount of Google searching, but either my keywords are not ideal or there really is no mention of this floating around (even the C++ pages that I read don't mention it). Thanks, mickmackusa
sscanf() and fscanf() may return -1 when the end of the input is reached before any value has been successfully parsed. That behaviour is currently missing from the documentation. I opened a PR to cover this: https://github.com/php/doc-en/pull/5580 Specific commit: https://github.com/php/doc-en/commit/7af7c98e4f7c983581dc05c58b958bb6c0c1267b Feel free to check and reply in the PR conversation if you think the wording should be adjusted. -- Regards, Jordi Kroon

« previous php.internals (#131007) next »