3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { private $isTrue = true; function foo() { echo 'foo'; $this->isTrue = false; } function bar() { echo 'bar'; } function baz() { if ($this->isTrue) { $this->foo(); } if (!$this->isTrue) { $this->bar(); } } } (new Foo)->baz();
Output for 8.1.1
foobar

preferences:
25.31 ms | 454 KiB | 5 Q