3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Expressions { function foo() { // Examples based on php-parser expression types static $array = [1, 2, 3], $arrayDimFetch = [1,2][0], $arrayItem = ['a' => 1], $binaryBitwiseAnd = 1 & 2, $binaryConcat = "a" . "b", $binaryIdentical = 1 === 1, $binaryPlus = 1 + 2, $binarySpaceship = 1 <=> 2, $bitwiseNot = ~1, $booleanAnd = 1 && 2, $booleanNot = !false, $classConstFetch = self::class, $coalesce = 1 ?? 2, $constFetch = PHP_EOL, $new = new stdClass(), $scalarFloat = 3.14, $scalarInteger = 123, $scalarMagicConst = __LINE__, $scalarString = 'string', $ternary = true ? 1 : 2, $unaryPlus = +1; } } $expr = new Expressions(); $expr->foo();
Output for 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.29, 8.4.1 - 8.4.16, 8.5.0 - 8.5.2

preferences:
70.64 ms | 406 KiB | 5 Q