summaryrefslogtreecommitdiff
path: root/UPGRADING
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-04-21 16:54:22 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-05-27 10:42:25 +0200
commit0221b8b2ab8cd53845a03cedb31add36e58e390f (patch)
tree8fa2ee16ccf477a0211fac9ad4e86ad9406be974 /UPGRADING
parent2423288f0f6244988e85f35b2e5a4c90a4e557a7 (diff)
downloadphp-git-0221b8b2ab8cd53845a03cedb31add36e58e390f.tar.gz
Add support for * width and precision in printf()
If * is used for width/precision in printf, then the width/precision is provided by a printf argument instead of being part of the format string. Semantics generally match those of printf in C. This can be used to easily reproduce PHP's float printing behavior: // Locale-sensitive using precision ini setting. // Used prior to PHP 8.0. sprintf("%.*G", (int) ini_get('precision'), $float); // Locale-insensitive using precision ini setting. // Used since to PHP 8.0. sprintf("%.*H", (int) ini_get('precision'), $float); // Locale-insensitive using serialize_precision ini setting. // Used in serialize(), json_encode() etc. sprintf("%.*H", (int) ini_get('serialize_precision'), $float); Closes GH-5432.
Diffstat (limited to 'UPGRADING')
-rw-r--r--UPGRADING7
1 files changed, 7 insertions, 0 deletions
diff --git a/UPGRADING b/UPGRADING
index 6f3abbfc7c..81b945d204 100644
--- a/UPGRADING
+++ b/UPGRADING
@@ -539,6 +539,13 @@ PHP 8.0 UPGRADE NOTES
. printf() and friends how support the %h and %H format specifiers. These
are the same as %g and %G, but always use "." as the decimal separator,
rather than determining it through the LC_NUMERIC locale.
+ . printf() and friends now support using "*" as width or precision, in which
+ case the width/precision is passed as an argument to printf. This also
+ allows using precision -1 with %g, %G, %h and %H. For example, the following
+ code can be used to reproduce PHP's default floating point formatting:
+
+ printf("%.*H", (int) ini_get("precision"), $float);
+ printf("%.*H", (int) ini_get("serialize_precision"), $float);
- Zip:
. Extension updated to version 1.19.0