php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #26993 [s]printf produces no output when too few arguments
Submitted: 2004-01-21 09:55 UTC Modified: 2015-02-26 07:26 UTC
Votes:2
Avg. Score:3.0 ± 2.0
Reproduced:1 of 2 (50.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: z-php at bart dot w-wa dot pl Assigned:
Status: Wont fix Package: *General Issues
PHP Version: 4.3.4 OS: Linux (Fedora Core 1)
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: z-php at bart dot w-wa dot pl
New email:
PHP Version: OS:

 

 [2004-01-21 09:55 UTC] z-php at bart dot w-wa dot pl
Description:
------------
"printf(): Too few arguments in..." is a warning, not an error. Yet, printf with too few arguments produces no output at all. IMHO, it should assume missing arguments to be NULL
(empty string, 0 etc.). 

Reproduce code:
---------------
printf('This will not print anything at all %s');


Expected result:
----------------
output: "This will not print anything at all "


Actual result:
--------------
Output: nothing. Only warning message if you have them turned on.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-02-26 07:26 UTC] krakjoe@php.net
-Status: Open +Status: Wont fix -Package: Feature/Change Request +Package: *General Issues
 [2015-02-26 07:26 UTC] krakjoe@php.net
Formatted printing is a functionality shared by many internal functions in the printf family, this is not something we want to change obviously.

Knowing this, we cannot assume anything if there are not enough arguments, since if not enough arguments are provided then there is no way to tell if the arguments received are in the correct order.

vsprintf("Hello %s, %s", ["World", "From PHP"]);
vsprintf("Hello %s, %s", ["From PHP"]);

Assuming missing arguments are null would result in printing utter nonsense in a lot of cases.

Sorry about the wait.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 20:01:45 2024 UTC