3v4l.org

run code in 300+ PHP versions simultaneously
<?php function distance($vect1, $vect2) { if (!is_array($vect1) || !is_array($vect2)) { return NULL; } if (count($vect1) != count($vect2)) { return NULL; } for ($i=0; $i<count($vect1); $i++) { $c1 = $vect1[$i]; $c2 = $vect2[$i]; $d = 0.0; if (!is_numeric($c1)) { trigger_error("Coordinate $i in vector 1 is not a number, using zero", E_USER_WARNING); $c1 = 0.0; } if (!is_numeric($c2)) { trigger_error("Coordinate $i in vector 2 is not a number, using zero", E_USER_WARNING); $c2 = 0.0; } $d += $c2*$c2 - $c1*$c1; return $d; echo sqrt($d); } return $d; } // variabile non definita, genera un warning $t = I_AM_NOT_DEFINED; // definisce dei vettori $a = array(2, 3, "foo"); $b = array(5.5, 4.3); $c = array(1, 3); // genera un errore utente distance($c, $b) . "\n"; // un'altro errore utente distance($b, "i am not an array") . "\n"; // genera un warning distance($a, $b) . "\n"; ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught Error: Undefined constant "I_AM_NOT_DEFINED" in /in/hMA5o:38 Stack trace: #0 {main} thrown in /in/hMA5o on line 38
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant I_AM_NOT_DEFINED - assumed 'I_AM_NOT_DEFINED' (this will throw an Error in a future version of PHP) in /in/hMA5o on line 38
Output for 4.3.0 - 4.3.11, 4.4.0 - 4.4.9, 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25
Notice: Use of undefined constant I_AM_NOT_DEFINED - assumed 'I_AM_NOT_DEFINED' in /in/hMA5o on line 38

preferences:
244.62 ms | 404 KiB | 371 Q