3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?PHP include 'pyhp.php'; if (!function_exists('gmp_sign')) { function gmp_sign($x) { return ($x<0?-1:1); } } function assertx($assertion, $failure="Assertion failed", $throwexception=true, $exception="ErrorException") { $assert_options = array(ASSERT_WARNING => 0, ASSERT_BAIL => 0, ASSERT_QUIET_EVAL => 1); foreach ($assert_options as $opt => $val) { $origval = assert_options($opt, $val); $assert_options[$opt] = $origval; } $test = assert($assertion); foreach ($assert_options as $opt => $val) { assert_options($opt, $val); } if ($test) return true; if (!$test) { if ($throwexception) throw new $exception($failure); return false; } } $xr = pyrange(-1, 1, 0.1); $yr = pyrange(-1, 1, 0.2); $eq = function($x, $y) { $c = function($i) { return $i*(180/pi()); }; $x = $c($x); $y = $c($y); if ($y == 0) return 90*gmp_sign($x); $a = round(180-$c(atan($x/$y)),0); if (gmp_sign($y) == -1) { $a -= 180; } return $a; }; assertx(gmp_sign(-0.5).'==-1'); assertx($eq(1, 1).'==135'); echo $eq(1, 1); echo PHP_EOL; echo $eq(-1, 1); echo PHP_EOL; echo $eq(-1, -1); echo PHP_EOL; echo $eq(1, -1); ?>
Output for 7.0.0 - 7.1.0
Warning: include(pyhp.php): failed to open stream: No such file or directory in /in/IhZ9N on line 3 Warning: include(): Failed opening 'pyhp.php' for inclusion (include_path='.:') in /in/IhZ9N on line 3 Fatal error: Uncaught Error: Call to undefined function pyrange() in /in/IhZ9N:28 Stack trace: #0 {main} thrown in /in/IhZ9N on line 28
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Warning: File not found: pyhp.php in /in/IhZ9N on line 3 Fatal error: Call to undefined function pyrange() in /in/IhZ9N on line 28
Process exited with code 255.
Output for 5.3.28 - 5.3.29, 5.4.20 - 5.6.28
Warning: include(pyhp.php): failed to open stream: No such file or directory in /in/IhZ9N on line 3 Warning: include(): Failed opening 'pyhp.php' for inclusion (include_path='.:') in /in/IhZ9N on line 3 Fatal error: Call to undefined function pyrange() in /in/IhZ9N on line 28
Process exited with code 255.
Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.19
Warning: include(pyhp.php): failed to open stream: No such file or directory in /in/i9Zdd on line 3 Warning: include(): Failed opening 'pyhp.php' for inclusion (include_path='.:') in /in/i9Zdd on line 3 Fatal error: Call to undefined function pyrange() in /in/i9Zdd on line 28
Process exited with code 255.
Output for 5.1.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION in /in/i9Zdd on line 31
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION in /in/i9Zdd on line 31
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_NEW in /in/i9Zdd on line 23
Process exited with code 255.
Output for 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_NEW in /in/i9Zdd on line 23
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/i9Zdd on line 23
Process exited with code 255.
Output for 4.3.0
Parse error: parse error, unexpected T_NEW in /in/IhZ9N on line 23
Process exited with code 255.