3v4l.org

run code in 300+ PHP versions simultaneously
<?php if (Term::create('oni')->in(['cheese', 'tomato', 'onion', 'pepperoni'])) { echo '"oni" is available in the given ingredients'.PHP_EOL; } else { echo '"oni" is NOT available in the given ingredients'.PHP_EOL; } if (Term::create('oni')->in('pepperoni')) { echo '"oni" is available in the given ingredient'.PHP_EOL; } else { echo '"oni" is NOT available in the given ingredient'.PHP_EOL; } // Pretend the following isn't here class Term { public $value; public function __construct($value) { $this->value = $value; } public static function create($value) { return new self($value); } public function in($search) { return array_reduce((array) $search, function ($carry, $item) { return $carry ?: (bool) mb_substr_count($item, $this->value); }); } public function notIn($search) { return !$this->in($array); } public function __toString() { return $this->value; } }
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.18, 8.5.0 - 8.5.3
Fatal error: Uncaught Error: Class "Term" not found in /in/ZfCBH:4 Stack trace: #0 {main} thrown in /in/ZfCBH on line 4
Process exited with code 255.
Output for 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
"oni" is available in the given ingredients "oni" is available in the given ingredient

preferences:
99.96 ms | 1565 KiB | 4 Q