4

You gotta love PHP:

<?php
$bool = true && false;
var_dump($bool); // false, that's expected

$bool = true and false;
var_dump($bool); // true, ouch!

Source: http://php.net/manual/de/...

http://php.net/manual/de/...

Comments
  • 3
    Both cases were expected by me.
  • 1
    @filthyranter They're only expected if you know the language really well (Most PHP developers don't know PHP well enough to be allowed to use the language in the real world)

    I would recommend banning those operators in your coding standards (Junior devs tend to screw those things up way too often and you can get the same functionality using &&/|| with extra parens)
  • 0
    @ItsNotMyFault I use && or || while coding, but that's a thing I learned while learning the language, that's why.
Add Comment