3v4l.org

run code in 300+ PHP versions simultaneously
<?hh /*-------------------------*\ $PROGRAM \*-------------------------*/ $zero = $f ==> $x ==> $x; $one = $f ==> $x ==> $f($x); $two = $f ==> $x ==> $f($f($x)); $three = $f ==> $x ==> $f($f($f($x))); $five = $f ==> $x ==> $f($f($f($f($f($x))))); $true = $x ==> $y ==> $x; $false = $x ==> $y ==> $y; $if = $f ==> $f; $isZero = $f ==> ($f($x ==> $false))($true); $increment = $n ==> $f ==> $x ==> $f(($n($f))($x)); $decrement = $n ==> $f ==> $x ==> (($n($g ==> $h ==> $h($g($f))))($y ==> $x))($y ==> $y); $add = $m ==> $n ==> ($n($increment))($m); $subtract = $m ==> $n ==> ($n($decrement))($m); $multiply = $m ==> $n ==> ($n($add($m)))($zero); $power = $m ==> $n ==> ($n($multiply($m)))($one); $cons = $x ==> $y ==> $f ==> ($f($x))($y); $car = $p ==> $p($x ==> $y ==> $x); $cdr = $p ==> $p($x ==> $y ==> $y); /*-------------------------*\ $DISPLAY HELPERS \*-------------------------*/ $toNum = $f ==> ($f($x ==> $x + 1))(0); $toBool = $f ==> (($if($f))(true))(false); $toTextBool = $f ==> $toBool($f) ? 'true' : 'false'; function it($m,$p){echo ($p?"32m✔":"31m✘")." It $m\n"; if(!$p)register_shutdown_function(function(){die(1);});} /*-------------------------*\ $TESTS \*-------------------------*/ it('has zero', $toNum($zero) === 0); it('has one', $toNum($one) === 1); it('has two', $toNum($two) === 2); it('has three', $toNum($three) === 3); it('has five', $toNum($five) === 5); it('has true', $toBool($true) === true); it('has false', $toBool($false) === false); it('can find zero values', $toBool($isZero($zero)) === true); it('can find non zero values', $toBool($isZero($three)) === false); it('can increment values', $toNum($increment($one)) === 2); it('can decrement values', $toNum($increment($three)) === 2); it('can add numbers', $toNum(($add($three))($one)) === 4); it('can subtract numbers', $toNum(($subtract($five))($two)) === 3); it('can multiply numbers', $toNum(($multiply($five))($three)) === 15); it('can calculate the power of numbers', $toNum(($power($three))($three)) === 27); $list = ($cons($one))($two); it('can find the car of a list', $toNum($car($list)) === 1); it('can find the cdr of a list', $toNum($cdr($list)) === 2); $bigList = ($cons($one))(($cons($two))($three)); it('can find the car of a big list', $toNum($car($bigList)) === 1); it('can find the cdar of a big list', $toNum($car($cdr($bigList))) === 2); it('can find the cddr of a big list', $toNum($cdr($cdr($bigList))) === 3);
Output for 7.2.29 - 7.2.33, 7.3.16 - 7.3.31, 7.4.3 - 7.4.32, 8.0.0 - 8.0.12, 8.0.14 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
<?hh /*-------------------------*\ $PROGRAM \*-------------------------*/ $zero = $f ==> $x ==> $x; $one = $f ==> $x ==> $f($x); $two = $f ==> $x ==> $f($f($x)); $three = $f ==> $x ==> $f($f($f($x))); $five = $f ==> $x ==> $f($f($f($f($f($x))))); $true = $x ==> $y ==> $x; $false = $x ==> $y ==> $y; $if = $f ==> $f; $isZero = $f ==> ($f($x ==> $false))($true); $increment = $n ==> $f ==> $x ==> $f(($n($f))($x)); $decrement = $n ==> $f ==> $x ==> (($n($g ==> $h ==> $h($g($f))))($y ==> $x))($y ==> $y); $add = $m ==> $n ==> ($n($increment))($m); $subtract = $m ==> $n ==> ($n($decrement))($m); $multiply = $m ==> $n ==> ($n($add($m)))($zero); $power = $m ==> $n ==> ($n($multiply($m)))($one); $cons = $x ==> $y ==> $f ==> ($f($x))($y); $car = $p ==> $p($x ==> $y ==> $x); $cdr = $p ==> $p($x ==> $y ==> $y); /*-------------------------*\ $DISPLAY HELPERS \*-------------------------*/ $toNum = $f ==> ($f($x ==> $x + 1))(0); $toBool = $f ==> (($if($f))(true))(false); $toTextBool = $f ==> $toBool($f) ? 'true' : 'false'; function it($m,$p){echo ($p?"32m✔":"31m✘")." It $m\n"; if(!$p)register_shutdown_function(function(){die(1);});} /*-------------------------*\ $TESTS \*-------------------------*/ it('has zero', $toNum($zero) === 0); it('has one', $toNum($one) === 1); it('has two', $toNum($two) === 2); it('has three', $toNum($three) === 3); it('has five', $toNum($five) === 5); it('has true', $toBool($true) === true); it('has false', $toBool($false) === false); it('can find zero values', $toBool($isZero($zero)) === true); it('can find non zero values', $toBool($isZero($three)) === false); it('can increment values', $toNum($increment($one)) === 2); it('can decrement values', $toNum($increment($three)) === 2); it('can add numbers', $toNum(($add($three))($one)) === 4); it('can subtract numbers', $toNum(($subtract($five))($two)) === 3); it('can multiply numbers', $toNum(($multiply($five))($three)) === 15); it('can calculate the power of numbers', $toNum(($power($three))($three)) === 27); $list = ($cons($one))($two); it('can find the car of a list', $toNum($car($list)) === 1); it('can find the cdr of a list', $toNum($cdr($list)) === 2); $bigList = ($cons($one))(($cons($two))($three)); it('can find the car of a big list', $toNum($car($bigList)) === 1); it('can find the cdar of a big list', $toNum($car($cdr($bigList))) === 2); it('can find the cddr of a big list', $toNum($cdr($cdr($bigList))) === 3);
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 <?hh /*-------------------------*\ $PROGRAM \*-------------------------*/ $zero = $f ==> $x ==> $x; $one = $f ==> $x ==> $f($x); $two = $f ==> $x ==> $f($f($x)); $three = $f ==> $x ==> $f($f($f($x))); $five = $f ==> $x ==> $f($f($f($f($f($x))))); $true = $x ==> $y ==> $x; $false = $x ==> $y ==> $y; $if = $f ==> $f; $isZero = $f ==> ($f($x ==> $false))($true); $increment = $n ==> $f ==> $x ==> $f(($n($f))($x)); $decrement = $n ==> $f ==> $x ==> (($n($g ==> $h ==> $h($g($f))))($y ==> $x))($y ==> $y); $add = $m ==> $n ==> ($n($increment))($m); $subtract = $m ==> $n ==> ($n($decrement))($m); $multiply = $m ==> $n ==> ($n($add($m)))($zero); $power = $m ==> $n ==> ($n($multiply($m)))($one); $cons = $x ==> $y ==> $f ==> ($f($x))($y); $car = $p ==> $p($x ==> $y ==> $x); $cdr = $p ==> $p($x ==> $y ==> $y); /*-------------------------*\ $DISPLAY HELPERS \*-------------------------*/ $toNum = $f ==> ($f($x ==> $x + 1))(0); $toBool = $f ==> (($if($f))(true))(false); $toTextBool = $f ==> $toBool($f) ? 'true' : 'false'; function it($m,$p){echo ($p?"32m✔":"31m✘")." It $m\n"; if(!$p)register_shutdown_function(function(){die(1);});} /*-------------------------*\ $TESTS \*-------------------------*/ it('has zero', $toNum($zero) === 0); it('has one', $toNum($one) === 1); it('has two', $toNum($two) === 2); it('has three', $toNum($three) === 3); it('has five', $toNum($five) === 5); it('has true', $toBool($true) === true); it('has false', $toBool($false) === false); it('can find zero values', $toBool($isZero($zero)) === true); it('can find non zero values', $toBool($isZero($three)) === false); it('can increment values', $toNum($increment($one)) === 2); it('can decrement values', $toNum($increment($three)) === 2); it('can add numbers', $toNum(($add($three))($one)) === 4); it('can subtract numbers', $toNum(($subtract($five))($two)) === 3); it('can multiply numbers', $toNum(($multiply($five))($three)) === 15); it('can calculate the power of numbers', $toNum(($power($three))($three)) === 27); $list = ($cons($one))($two); it('can find the car of a list', $toNum($car($list)) === 1); it('can find the cdr of a list', $toNum($cdr($list)) === 2); $bigList = ($cons($one))(($cons($two))($three)); it('can find the car of a big list', $toNum($car($bigList)) === 1); it('can find the cdar of a big list', $toNum($car($cdr($bigList))) === 2); it('can find the cddr of a big list', $toNum($cdr($cdr($bigList))) === 3);
Output for 8.0.13
Parse error: syntax error, unexpected variable "$zero" in /in/5nAq7 on line 6
Process exited with code 255.
Output for 5.4.0 - 5.4.31, 5.5.0 - 5.5.15, 7.3.32 - 7.3.33, 7.4.33
Parse error: syntax error, unexpected '$zero' (T_VARIABLE) in /in/5nAq7 on line 6
Process exited with code 255.

preferences:
161.56 ms | 402 KiB | 185 Q