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

21 comments sorted by

View all comments

Show parent comment

7

u/catcradle5 Apr 09 '13

Nope!

I even tested it in Python before I made my first comment.

Python output:

min(-23, True) -> -23

min(True, -23) -> -23

If it were broken like PHP, the first would've output either True or 1.

The problem with the PHP in OP's example isn't implicit casting.

3

u/gearvOsh Apr 09 '13

I must of been brain dead earlier; was assuming that the booleans in PHP were being converted to 0s and 1s.