Req #26993 [Opn->Wfx]: [s]printf produces no output when too few arguments
| From: | krakjoe@php.net | Date: | Thu, 26 Feb 2015 07:26:01 +0000 |
| Subject: | Req #26993 [Opn->Wfx]: [s]printf produces no output when too few arguments | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-190956@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=26993&edit=1
ID: 26993
Updated by: krakjoe@php.net
Reported by: z-php at bart dot w-wa dot pl
Summary: [s]printf produces no output when too few arguments
-Status: Open
+Status: Wont fix
Type: Feature/Change Request
-Package: Feature/Change Request
+Package: *General Issues
Operating System: Linux (Fedora Core 1)
PHP Version: 4.3.4
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2004-01-21 09:55:07] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=26993&edit=1