php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #73895 Missing format variation
Submitted: 2017-01-09 10:33 UTC Modified: 2017-01-09 10:48 UTC
Votes:4
Avg. Score:3.8 ± 1.1
Reproduced:4 of 4 (100.0%)
Same Version:2 (50.0%)
Same OS:1 (25.0%)
From: h dot larget at gmail dot com Assigned:
Status: Not a bug Package: *Math Functions
PHP Version: 7.0.14 OS: Ubuntu 16.04 LTS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
25 + 4 = ?
Subscribe to this entry?

 
 [2017-01-09 10:33 UTC] h dot larget at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/function.round
---

It is not specified that depending on php locale, the dot is replaced by comma.

it should not have this kind of behavior or being specified in the documentation.

Test script:
---------------
<?php echo "<br/>".round(2.447,2);

Expected result:
----------------
<br/>2.45

Actual result:
--------------
<br/>2,45

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2017-01-09 10:48 UTC] requinix@php.net
-Status: Open +Status: Not a bug -Package: Documentation problem +Package: *Math Functions
 [2017-01-09 10:48 UTC] requinix@php.net
It is not mentioned because it has nothing to do with round(). The comma is introduced when the floating-point value is converted to string.
http://php.net/manual/en/language.types.string.php#language.types.string.casting

echo 2.447; // 2.447
echo (string)2.447; // 2,447 with an appropriate locale
 
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Wed Mar 03 15:01:24 2021 UTC