Electronic Elves Residence
Add
{code} {code} == == * * _ _ [] * #

196

2017-01-12 12:00:56
class I {
    static $i = 0;
    public function __construct($val)
    {
        $this->val = $val;
        $this->cnt = ++self::$i;
    }
    public function __invoke() {
        echo "called for ", $this->cnt, PHP_EOL;
        return $this->val;
    }
}

$f = function($a, $b) {
    return $a && !$b || !$a && $b;
};

foreach([true, false] as $a)
{
    $a = new I($a);
    foreach([true, false] as $b)
    {
        $b = new I($b);
//        var_dump($a, $b, $a() && !$b() || !$a() && $b());
        var_dump($a, $b, $a() xor $b());
        echo PHP_EOL, PHP_EOL;
    }
}