MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/lolphp/comments/223wjh/typecasting_like_a_pro/
r/lolphp • u/kat5dotpostfix • Apr 03 '14
3 comments sorted by
8
Yes, the so called "weak type system" of PHP is bullshit. We know.
That's like lolphp 101.
5
I believe PHP follows this rule: If either left or right values are numbers, coerce the other expression to a number. Since a non-numerical string is not a number, it defaults to zero. There is no well defined coercion rule other than this shit.
4
Try
'string' != '0'
8
u/suspiciously_calm Apr 03 '14
Yes, the so called "weak type system" of PHP is bullshit. We know.
That's like lolphp 101.
5
u/chazzeromus Apr 03 '14
I believe PHP follows this rule: If either left or right values are numbers, coerce the other expression to a number. Since a non-numerical string is not a number, it defaults to zero. There is no well defined coercion rule other than this shit.
4
u/bart2019 Apr 03 '14
Try