News for hackers. Stuff that matters.
Re:PHP Bug: #50696: number_format when passed a 0, returns null by vlucas on Sunday January 10, 2010 @03:13PM (#1043570)
This is funny because it's not really a bug at all. I side with the PHP guys on this one. Passing in a string to a number_format function is not even proper form in the first place. I do agree that it should always default to 0 instead of null because it is a numeric function, but still. The usage is the main problem in this case - and who wants to fix a bug for an asshole anyways?

A lesson to all who rely on edge cases and un-documented behaviors for functionality.

Re:PHP Bug: #50696: number_format when passed a 0, returns null by smallblacksun on Sunday January 10, 2010 @04:58PM (#1043735)
number_format returns a string - I would expect it to return null rather than 0 for bad input
Re:PHP Bug: #50696: number_format when passed a 0, returns null by rbanffy on Sunday January 10, 2010 @06:05PM (#1043862)
+1.

It should thrown an exception and abort the script with an ugly error traceback.

If the documentation says "float" and you can hand it a numerical string, then either the function or its documentation have a bug that needs correcting.

Re:PHP Bug: #50696: number_format when passed a 0, returns null by bozmac on Sunday January 10, 2010 @10:38PM (#1044253)
I wouldn't go as far as throwing an exception. A notice maybe.
Re:PHP Bug: #50696: number_format when passed a 0, returns null by rbanffy on Monday January 11, 2010 @07:06AM (#1044913)
Asking a function that formats a number and that is defined that way in the documentation to format a string is a programming mistake. As the discussion clearly states, it's a minor change in application code that would make it both clearer and more robust.

I would go as far as recommend using a USB shock device to issue a warning to the programmer every times a mistake like this is made. ;-)