r/lolphp • u/i_make_snow_flakes • Nov 15 '14
new safe casting function RFC. casting "-10" to string is valid but casting "+10" is not..
here the comment where one user asked the author of RFC about this. I am not able to follow his reasoning. What do you think?
22
Upvotes
27
u/[deleted] Nov 15 '14 edited Nov 15 '14
C's and C++'s atoi both accept "+1"
JavaScript's parseInt accepts "+1"
Perl accepts "+1"
S/He's violating the principle of least surprise
then again, idiotic code for PHP is no surprise either
2
u/rafalfreeman Dec 03 '14
He is insane, but well that is not a surprise, he develops PHP.
0
u/YouAintGotToLieCraig Nov 18 '14
You should have used a "np" link to discourage vote brigading
http://np.reddit.com/r/PHP/comments/2m85jr/rfc_safe_casting_functions_v014/cm24cfr
-1
u/[deleted] Nov 15 '14 edited Nov 15 '14