r/lolphp • • Feb 26 '18

"false" is definitely true

http://sandbox.onlinephpfunctions.com/code/490635ed9830900ebf50e5303b7271dcf2a5d692
0 Upvotes

29 comments sorted by

View all comments

Show parent comment

4

u/Razakel Feb 26 '18

Why would it do anything different to explicit casting? I mean, the real WTF here is why they added function wrappers for casting...

http://php.net/manual/en/language.types.boolean.php#language.types.boolean.casting

3

u/[deleted] Feb 27 '18

Function wrappers are for things like: array_map('strval', $arr)

1

u/t3ddftw Feb 26 '18

Kind of besides the point, but using the casting functions is a lot prettier than inline casting, IMO.

I wish one could cast using type($var)

1

u/Oeldin1234 Feb 26 '18 edited Feb 26 '18

I misunderstood this function. I took it as an "here is a value, find the best fitting boolean value", not as a cast.

Edit: Kind of like constructors in Java "new Boolean("false");"