#50696 [Opn->WFx]: number_format when passed a 0 as first function argument, returns null
From: rasmus@php.net Date: Fri, 08 Jan 2010 19:20:29 +0000 Subject: #50696 [Opn->WFx]: number_format when passed a 0 as first function argument, returns null References: 1 Groups: php.bugs Request: Send a blank email to php-bugs+get-146443@lists.php.net to get a copy of this message
ID: 50696
Updated by: rasmus@php.net
Reported By: endosquid at endosquid dot com
-Status: Open
+Status: Wont fix
Bug Type: Math related
Operating System: Linux 32 bit
PHP Version: 5.3.1
New Comment:
Why are you passing an empty string in place of a number there? You
are essentially asking for an empty string to be printed with 0 decimal
places and you are getting back an empty string. You also get a big
warning about that, of course. How about "a",0 what do you expect that
to return?
I think the right solution for you here is to be explicit about casting
your weird inputs to a float. number_format((float)$weird,'0') will
take care of it.
Previous Comments:
------------------------------------------------------------------------
[2010-01-08 19:13:41] endosquid at endosquid dot com
Description:
------------
php -r 2>/dev/null 'print number_format("",0) . "\n";'
on our old PHP 5.1.6 Solaris 8 box (that we are transitioning off of)
returns 0.
Now, we're testing our code, and we run into this behavior change:
php -r 2>/dev/null 'print number_format("",0) . "\n";'
on our new RHEL5 with 5.3.1 from the REMI repository returns NULL. Is
this the default behavior expected? If so, why did this change happen?
If not, where did we go wrong?
Reproduce code:
---------------
php -r 2>/dev/null 'print number_format("",0) . "\n";'
Expected result:
----------------
We expect to see 0 returned, not NULL.
Actual result:
--------------
NULL is returned.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50696&edit=1
Thread (21 messages)
- #50696 [Opn->WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- #50696 [WFx]: number_format when passed a 0 as first function argument, returns null
- Bug #50696 [Com]: number_format when passed a 0 as first function argument, returns null
- Bug #50696 [Com]: number_format when passed a 0 as first function argument, returns null
- Bug #50696 [Com]: number_format when passed a 0 as first function argument, returns null
- Bug #50696 [Com]: number_format when passed a 0 as first function argument, returns null
- Bug #50696 [Wfx]: number_format when passed a 0 as first function argument, returns null
- Bug #50696 [Com]: number_format when passed a 0 as first function argument, returns null
- Bug #50696 [Com]: number_format when passed a 0 as first function argument, returns null
- Bug #50696 [Com]: number_format when passed a 0 as first function argument, returns null
- Bug #50696 [Com]: number_format when passed a 0 as first function argument, returns null
| « previous | php.bugs (#146443) | next » |
|---|