PHP Bug: #50696: number_format when passed a 0, returns null
1–10 of 51 posts
Re: PHP Bug: #50696: number_format when passed a 0, returns null
#2Always use what is documented so you don't have to cry later..
Re: PHP Bug: #50696: number_format when passed a 0, returns null
#3Classic.
Re: PHP Bug: #50696: number_format when passed a 0, returns null
#4"Escalate? Oh how I wish I had someone to escalate to." Classic.
Re: PHP Bug: #50696: number_format when passed a 0, returns null
#5Interesting discussion in there, but I think the PHP guys are right on this one. You should never rely on undefined behavior of any API for mission critical code. Always use what is documented so you don't have to cry later..
Different 'bug', similar theme: I'd be v. interested to hear what HN folks think about http://bugs.php.net/bug.php?id=47494. I explained the problem here: http://insomanic.me.uk/post/191397106/php-htmlspecialchars-h...
Summary: PHP 5.3 introduces a scenario where:
display_errors=off, log_errors=on => warning msg is logged (but not displayed, of course..)
display_errors=on => NO warning is logged OR displayed(?!)
Took me ages to figure out, that one did..Re: PHP Bug: #50696: number_format when passed a 0, returns null
#6Interesting discussion in there, but I think the PHP guys are right on this one. You should never rely on undefined behavior of any API for mission critical code. Always use what is documented so you don't have to cry later..
My vote for the other side is because php guys didn't document the change. Other pages show exactly what happens in strange cases - like in "If delimiter is an empty string (""), explode() will return FALSE." There's no mention about the change on http://php.net/manual/en/function.number-format.php and they list the result as "string" without any other notes. Making the function backwards compatible wouldn't hurt anyone either, because it would restore the behaviour for people using "" and would change nothing for ones using normal values all the time and ones who started casting to a number because of this change. But yes - it's pretty much php guys' call.
Re: PHP Bug: #50696: number_format when passed a 0, returns null
#7From the report: "Each of those changes will have to be coded, tested, written-off, released, tested by the clients since this is tax data and has to be precise for tax planning and retirement planning."
From the documentation: "string number_format ( float $number [, int $decimals ] )"
Re: PHP Bug: #50696: number_format when passed a 0, returns null
#8Interesting discussion in there, but I think the PHP guys are right on this one. You should never rely on undefined behavior of any API for mission critical code. Always use what is documented so you don't have to cry later..
Re: PHP Bug: #50696: number_format when passed a 0, returns null
#9Re: PHP Bug: #50696: number_format when passed a 0, returns null
#10A lesson to all who rely on edge cases and un-documented behaviors for functionality.