Req #63928 [Opn->Wfx]: unexpected behaviour of sprintf

From: Date: Mon, 07 Jan 2013 10:27:06 +0000
Subject: Req #63928 [Opn->Wfx]: unexpected behaviour of sprintf
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-175813@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63928&edit=1 ID: 63928 Updated by: cataphract@php.net Reported by: Mikayuoads at gmail dot com Summary: unexpected behaviour of sprintf -Status: Open +Status: Wont fix Type: Feature/Change Request Package: Unknown/Other Function Operating System: Gentoo PHP Version: 5.4.10 Block user comment: N Private report: N New Comment: The sprintf() function specified for the C standard, and upon which PHP's function is based explicitly says that "[i]f the 0 and-flags both appear, the 0 flag is ignored." Implementing different behavior in PHP would be ill-advised. Previous Comments: ------------------------------------------------------------------------ [2013-01-07 09:19:29] Mikayuoads at gmail dot com Description: ------------ --- From manual page: http://www.php.net/function.sprintf#refsect1-function.sprintf-seealso --- Right padding doesn't work with zeros. Test script: --------------- echo sprintf('%\'0-5d', 42); // output: '42 ' echo sprintf('%0-5d', 42); // output: '42 ' echo sprintf('%\'#-5d', 42); // output: '42###' Expected result: ---------------- expected result: echo sprintf('%\'0-5d', 42); // output: '42000' echo sprintf('%0-5d', 42); // output: '42000' echo sprintf('%\'#-5d', 42); // output: '42###' ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=63928&edit=1

« previous php.bugs (#175813) next »