|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-07-30 19:28 UTC] mike@php.net
-Type: Bug
+Type: Documentation Problem
-Package: Output Control
+Package: Documentation problem
[2013-10-09 06:16 UTC] krakjoe@php.net
[2013-10-09 06:16 UTC] krakjoe@php.net
-Status: Open
+Status: Closed
-Assigned To:
+Assigned To: krakjoe
[2013-10-09 06:16 UTC] krakjoe@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 04 08:00:01 2025 UTC |
Description: ------------ Nothing unique about my configuration; I've tried this on several different machines with different PHP versions and received the same result. When I attempt to use the %c formatting code with (for example, sprintf()), it ignores any width specifier that I indicate, as in the example code below. I saw nothing in the documentation that the %c code would not react to a width specifier any differently than the other data formats. Test script: --------------- <pre> <?php $x = ord('A'); echo sprintf("|%c|\n",$x); echo sprintf("|%1c|\n",$x); echo sprintf("|%2c|\n",$x); echo sprintf("|%3c|\n",$x); echo sprintf("|%4c|\n",$x); echo sprintf("|%5c|\n",$x); echo sprintf("|%6c|\n",$x); echo sprintf("|%7c|\n",$x); echo sprintf("|%-8c|\n\n\n",$x); ?> Expected result: ---------------- |A| |A| | A| | A| | A| | A| | A| | A| |A | (I expected this because this is what the equivalent code in C produces) Actual result: -------------- |A| |A| |A| |A| |A| |A| |A| |A| |A|