|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2012-03-27 21:28 UTC] iblue at gmx dot net
Description:
------------
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:
---------------
<?php
echo sprintf("%'.9s\n", "foo");
echo sprintf("%'.09s\n", "foo");
Expected result:
----------------
......foo
......foo
Actual result:
--------------
......foo
000000foo
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 20:00:01 2025 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 000000123