UNPKG

phpjs

Version:

php.js offers community built php functions in javascript

44 lines (30 loc) 1.67 kB
<!-- Generated by Rakefile:build --> <strong> Robin </strong> on 2008-10-28 18:13:54 <br /> I'm sorry I was a douche :( <hr /> <strong> Onno Marsman </strong> on 2008-10-10 15:45:46 <br /> Never really thought of using a regular expression to test whether a string would result in an error and you're right: that would probably be a lot better. Feel free to post your suggestion, otherwise I'll have a look at it myself tomorrow. Furthermore: is_nan in PHP behaves very differently from isNaN in javascript. Javascripts isNaN is more like the opposite of PHPs is_numeric function (Just have a look at the implementation of is_numeric in this library). So a simple wrapper to isNaN won't suffice and the extra check for the number type is needed. The rest of the code in this function is just to generate errors in the same way PHP does. And the suggested regular expression will, of course, make this code a lot shorter. Note that is_finite and is_infinite both contain the exact same error code. I will fix this too. <hr /> <strong> <a href="http://kevin.vanzonneveld.net" rel="nofollow">Kevin van Zonneveld</a> </strong> on 2008-10-10 15:05:10 <br /> @ Robin: I agree that this may look a bit elaborate, but if I remember correctly, Onno Marsman had some very good reasons for implementing it this way. I'll ask him to comment you on the specifics. <hr /> <strong> Robin </strong> on 2008-10-10 12:05:58 <br /> ... I'm sorry but this is laughable. isNaN duplicates this functionality. Just write a wrapper. If you're really bothered, a simple regexp could also do the trick just as easily. This is just getting on the edge of silly now. <hr />