|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #61532 Apostrophe modifier in *printf is broken
Submitted: 2012-03-27 21:28 UTC Modified: 2015-01-14 14:56 UTC
From: iblue at gmx dot net Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.4.0 OS: GNU/Linux
Private report: No CVE-ID: None
 [2012-03-27 21:28 UTC] iblue at gmx dot net
When I use the apostrophe (') modifier to select a padding character in printf, 
it behaves buggy, when the padding length itself is prefixed by zeroes.

Test script:
echo sprintf("%'.9s\n", "foo");
echo sprintf("%'.09s\n", "foo");

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-12 10:09 UTC]
The current behaviour seems to be in line with what libc does, both on Linux and Solaris (and gcc and suncc):

$ cat test.c
#include <stdio.h>

void main() {
	printf("%'.09i\n", 123);

$ gcc -otest test.c
$ ./test 
 [2012-04-12 10:13 UTC]
-Type: Bug +Type: Documentation Problem
 [2012-04-12 10:13 UTC]
It should be  documented that 0 as padding specifier overwrites a manually set one.
 [2015-01-14 14:55 UTC]
Automatic comment from SVN on behalf of danack
Log: Added detail about padding character for bug 61532
 [2015-01-14 14:56 UTC]
-Status: Open +Status: Not a bug
 [2015-01-14 14:56 UTC]
It has been documented that 0 as padding specifier overwrites a manually set one.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Aug 07 21:01:25 2020 UTC