3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Foo { const TYPE_BUFFER = 1; const TYPE_PICKING = 2; const TYPE_CONTAINER = 4; const TYPE_SHIPMENT = 8; const TYPE_ALL = 15; private $type; public function __construct($type) { $this->type = $type; } public function allowAdd() { return ($this->type & self::TYPE_BUFFER + self::TYPE_PICKING) !== 0; } public function allowAddAll() { return ($this->type & self::TYPE_ALL) !== 0; } } var_dump((new Foo(Foo::TYPE_BUFFER))->allowAdd()); var_dump((new Foo(Foo::TYPE_PICKING))->allowAdd()); var_dump((new Foo(Foo::TYPE_CONTAINER))->allowAdd()); var_dump((new Foo(Foo::TYPE_SHIPMENT))->allowAdd()); echo PHP_EOL; var_dump((new Foo(Foo::TYPE_BUFFER))->allowAddAll()); var_dump((new Foo(Foo::TYPE_PICKING))->allowAddAll()); var_dump((new Foo(Foo::TYPE_CONTAINER))->allowAddAll()); var_dump((new Foo(Foo::TYPE_SHIPMENT))->allowAddAll()); var_dump((new Foo(16))->allowAddAll()); var_dump((new Foo(31))->allowAddAll()); var_dump((new Foo(0))->allowAddAll()); var_dump((new Foo(-16))->allowAddAll());
based on 9qo80
Output for 5.6.0 - 5.6.38, hhvm-3.15.4, 7.0.0 - 7.3.0
bool(true) bool(true) bool(false) bool(false) bool(true) bool(true) bool(true) bool(true) bool(false) bool(true) bool(false) bool(false)