Skip to content

standard: Improve sprintf() error message when providing an empty arg specifier - #23706

Open
TimWolla wants to merge 1 commit into
php:masterfrom
TimWolla:sprintf-empty-argnum-better-error
Open

TimWolla wants to merge 1 commit into
php:masterfrom
TimWolla:sprintf-empty-argnum-better-error

Conversation

@TimWolla

Copy link
Copy Markdown
Member

I misremembered the correct syntax for specifying the argnum in an sprintf() format string and placed the number after the $ instead of before. This lead to sprintf() seeing an empty number and reporting:

Argument number specifier must be greater than zero and less than 2147483647

which was misleading. Had the error message shown that the argnum is empty, it would have been much clearer that it expect the number before the $.

…rg specifier

I misremembered the correct syntax for specifying the argnum in an `sprintf()`
format string and placed the number after the `$` instead of before. This lead
to `sprintf()` seeing an empty number and reporting:

> Argument number specifier must be greater than zero and less than 2147483647

which was misleading. Had the error message shown that the argnum is empty, it
would have been much clearer that it expect the number before the `$`.
@TimWolla
TimWolla force-pushed the sprintf-empty-argnum-better-error branch from 2f1d35e to 8ce5513 Compare September 16, 2026 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants