|
|
|
|
|
by chris_wot
5092 days ago
|
|
I know! In PHP, try the equivalent: print intval(NaN, 19);
Result in PHP 5.2.17 is: 0
Clearly, that is correct.PHP does the following: intval('42', 8); // => 34
intval(42, 8); // => 42
Now try: print intval(strval("19.99"*100));
print "<br>";
print intval("19.99"*100);
This returns: 1999
1998
|
|
Unrelated, it seems like intval(1/0, 19) in PHP also returns 0 because 1) intval returns 0 if given an empty string (JavaScript's parseInt returns NaN if given an empty string) and 2) 1/0 seems to return something hilarious... it converts to "", but gettype() on it returns "boolean"... I sadly don't know PHP well enough to understand what it is ;P.