php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #44162 number_format() list incorrect optional parameters
Submitted: 2008-02-18 20:53 UTC Modified: 2008-02-19 11:51 UTC
From: me at edman007 dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: N/A
Private report: No CVE-ID: None
 [2008-02-18 20:53 UTC] me at edman007 dot com
Description:
------------
on the number_format page (http://us2.php.net/number_format) the parameters for it are listed as:

string number_format  ( float $number  [, int $decimals  [, string $dec_point  ]], string $thousands_sep  )

that is wrong, it suggests that when two parameters are given its $number, $thousands_sep), its not, instead like most functions it works left to right, with the exception that there is no valid form with three parameters, that means it should look like this

string number_format  ( float $number  [, int $decimals  [, string $dec_point, string $thousands_sep]])

that would indicate that its one two, for 4 parameters

and to quote from the docs on this issue, 'All optional parameters are seen in [ brackets ].' (http://us2.php.net/manual/en/about.prototypes.php), $thousands_sep is obviously optional but not in brackets

Reproduce code:
---------------
$a = 12345678.901;
echo number_format($a,2);
//12,345,678.90

//the prototype suggest this may be valid, though the docs below it say its wrong
echo number_format($a, 2, 'x');
//PHP Warning:  Wrong parameter count for number_format() in XXX- on line 5

echo number_format($a, 2, '.', ',');
//12,345,678.90

//this is wrong, but according to the docs should be correct
echo number_format($a,' ');        
//12,345,679


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-02-19 11:51 UTC] rquadling@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

Due to docbook not currently supporting a technique to group optional parameters, a second description has been added.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Thu Oct 08 12:00:01 2026 UTC