It returned 0 previously for "", why change it now? Was "" == 0 a bug ?
It returned 0 previously for "", why change it now? Was "" == 0 a bug ?
B) The change was discovered as a difference in behaviour in two major releases that were three years apart.
C) Rasmus Lerdorf can change PHP however he wants. It is precisely because of this that PHP has been so {'widely success', 'pain'}ful.
D) The reporter was being overly dramatic regarding the change going to take a supposedly crazy amount of time to fix.
E) You don't pass a string into a function that's usually returning a string without at least casting to a string when part of its intended behaviour is at times not returning a string. Casting in this case even before the function even changed would have been an exceedingly good idea.
F) (edit) I vote we burn in hell PHP developers who tack on comments to a long closed bug report to offer their opinions like joezimjs did. Especially when they display a basic ignorance in saying crap like "NULL is neither a string nor a number."
What I don't get is that they are keen to modify php source. But not to just keep using the same php release?
I agree with E, they take floats not strings apparently.
The moment you run a patched build, you're IMHO not running the officially sanctioned version any more.
I tell you that you have no apples. Write the number of apples you have on a piece of paper. What did you write? I bet it was 0, not some arbitrary, non-writable symbol for an abstract concept that could mean "nothing" or "error" or "empty" or ..
How can the answer to an unfinished question be "0"? 0 is an actual valid answer, when people are asking for number_format(0, 0).
In this case, NULL is definitely more appropriate, because the input is invalid.
Well in PHP, the number for <silence> is 0, so it would stand to reason that the formatted number for <silence> is 0 as well.
Your analogy is a misunderstanding of null. Null is like you asking me how many apples Joe has. I say I don't know. If you write down 0, I'm going to stop you and say, "I didn't say zero, I said I don't know."
If I were in charge of PHP, release 6 would be 5.4.4 with the standard library happily throwing exceptions on invalid input. That's it. The language would be 100% more useful instantly.
According to the php docs
floatval('122.34343The') == 122.34343
floatval('BLARTLBARTFAST') == 0
Why should it take the input and choose a different response than what floatval would respond with?
If floatval returns null on 'BLARTLBARTFAST' and '122.34343The' then this function should return null. If floatval returns 0 (or whatever) than this function should return the same.
It's inconsistent behavior.
Since you quite clearly have no idea what function we're even talking about or what it's supposed to do, I will just point you to the documentation rather than more explicitly explain on how many levels you are wrong: http://www.php.net/manual/en/function.number-format.php
The function requires a float, and the developer is passing in an empty string. To rely on this type of edge-case behavior is ridiculous, in my opinion.
[1] http://php.net/number-format says the first argument expects float, and does not say what happens if it receives non-floats.
Sounds like that's what 'zend_parse_parameters' does, actually.
php -r 'print number_format("",0) . "\n";'
PHP Warning: number_format() expects parameter 1 to be double, string given in Command line code on line 1