3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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 7.0.0 - 7.1.0
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.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.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.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