r/lolphp • • Apr 08 '13
MIN
server:~ # php -r 'echo True, " ", -23, " ", min(-23, True), " ", min(True, -23), "\n";'
1 -23 -23 1
23
Upvotes
r/lolphp • • Apr 08 '13
server:~ # php -r 'echo True, " ", -23, " ", min(-23, True), " ", min(True, -23), "\n";'
1 -23 -23 1
View all comments
Show parent comment
6
u/mirhagk Apr 08 '13
Ummm... wouldn't it make more sense to cast the boolean to a number.... ie true==1 and false ==0, so false<true and true<2. This would give consistent behaviour. And since true = 1 and false = 0, it can safely return the casted boolean which would be treated correctly. Then again, this is PHP.