3v4l.org

run code in 300+ PHP versions simultaneously
<?php function calculValeurEcoGes($valeur, $type = 1) { $intervalles = array( // Indice 1= Eco, Indice 2=GES 1 => array ('A' => array(0, 50), 'B' => array(51, 90), 'C' => array(91, 150), 'D' => array(151, 230), 'E' => array(231, 330), 'F' => array(331, 450), G => array(451, 99999)), 2 => array('A' => array(0, 5), 'B' => array(6, 10), 'C' => array(11, 20), 'D' => array(21, 35), 'E' => array(36, 55), 'F' => array(56, 80), 'G' => array(81, 99999)) ); if($type < 1 || $type > 2) { exit("Erreur, le type de valeur éco. doit être compris entre 1 et 2"); } $intervalle = $intervalles($type); foreach($intervalle as $lettre => $minMax) { list($min, $max) = $minMax; if($valeur >= $min && $valeur <= $max) { return $lettre; } } return 'Z'; } echo calculValeurEcoGes(40, 1);
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 "G" in /in/DJh8B:5 Stack trace: #0 /in/DJh8B(20): calculValeurEcoGes(40, 1) #1 {main} thrown in /in/DJh8B on line 5
Process exited with code 255.
Output for 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33
Warning: Use of undefined constant G - assumed 'G' (this will throw an Error in a future version of PHP) in /in/DJh8B on line 5 Fatal error: Uncaught Error: Array callback has to contain indices 0 and 1 in /in/DJh8B:11 Stack trace: #0 /in/DJh8B(20): calculValeurEcoGes(40, 1) #1 {main} thrown in /in/DJh8B on line 11
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20
Notice: Use of undefined constant G - assumed 'G' in /in/DJh8B on line 5 Fatal error: Uncaught Error: Array callback has to contain indices 0 and 1 in /in/DJh8B:11 Stack trace: #0 /in/DJh8B(20): calculValeurEcoGes(40, 1) #1 {main} thrown in /in/DJh8B on line 11
Process exited with code 255.
Output for 5.4.8 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Notice: Use of undefined constant G - assumed 'G' in /in/DJh8B on line 5 Fatal error: Array callback has to contain indices 0 and 1 in /in/DJh8B on line 11
Process exited with code 255.
Output for 5.4.0 - 5.4.7
Notice: Use of undefined constant G - assumed 'G' in /in/DJh8B on line 5
Process exited with code 139.
Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29
Notice: Use of undefined constant G - assumed 'G' in /in/DJh8B on line 5 Fatal error: Function name must be a string in /in/DJh8B on line 11
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Notice: Use of undefined constant G - assumed 'G' in /in/DJh8B on line 5 Notice: Array to string conversion in /in/DJh8B on line 11 Fatal error: Call to undefined function: array() in /in/DJh8B on line 11
Process exited with code 255.
Output for 4.3.2 - 4.3.11, 4.4.0 - 4.4.4
Notice: Use of undefined constant G - assumed 'G' in /in/DJh8B on line 5 Notice: Array to string conversion in /in/DJh8B on line 11 Fatal error: Call to undefined function: array() in /in/DJh8B on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Notice: Use of undefined constant G - assumed 'G' in /in/DJh8B on line 5 Notice: Array to string conversion in /in/DJh8B on line 11 Fatal error: Call to undefined function: array() in /in/DJh8B on line 11

preferences:
242.77 ms | 402 KiB | 357 Q