Doc #78165 [Opn->Ver]: Incorrect example with printf
| From: | cmb@php.net | Date: | Fri, 14 Jun 2019 17:42:34 +0000 |
| Subject: | Doc #78165 [Opn->Ver]: Incorrect example with printf | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-16753@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=78165&edit=1
ID: 78165
Updated by: cmb@php.net
Reported by: cfesting at yahoo dot com
Summary: Incorrect example with printf
-Status: Open
+Status: Verified
Type: Documentation Problem
Package: Strings related
PHP Version: Irrelevant
-Assigned To:
+Assigned To: cmb
Block user comment: N
Private report: N
Previous Comments:
------------------------------------------------------------------------
[2019-06-14 17:13:05] requinix@php.net
It's kinda left-justified, kinda not, depending how you look at it.
So how about we ignore the problem entirely and change the example instead?
printf("[%20.10s]\n", $t); // right-justification but with a cutoff of 10 characters
printf("[%-20.10s]\n", $t); // left-justification but with a cutoff of 10 characters
with output
[ many monke]
[many monke ]
------------------------------------------------------------------------
[2019-06-14 17:09:57] girgias@php.net
The output is [many monke] which seems left-justified to me.
See https://3v4l.org/68s7r
------------------------------------------------------------------------
[2019-06-14 17:02:32] cfesting at yahoo dot com
Description:
------------
---
From manual page: https://php.net/function.printf
---
In example #2:
printf("[%10.10s]\n", $t); // left-justification but with a cutoff of 10 characters
It is my belief that the above will be right-justified, not left.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=78165&edit=1