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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
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: Sun May 05 09:01:30 2024 UTC