3v4l.org

run code in 300+ PHP versions simultaneously
<?php class TiroNaCara extends Exception { public function __construct($grito){ parent::__construct("Você levou tiro na cara: " . strtoupper($grito)); } } class LojaDeCrack { private $pacotes = array(); private function checarPacotes($oQueFazer){ $pacotes = $this -> pacotes; foreach($pacotes as $pedraDoPacote) $oQueFazer($pedraDoPacote); } public function __construct($pacotes){ if(gettype($pacotes) == "array" && !empty($pacotes)){ checarPacotes(function($pedraDoPacote){ if(!is_numeric($pedraDoPacote)) throw new TiroNaCara("CLIENTE BURRO DO CARALHUDO DE UMAS ARÁBIAS! AFF"); }); $this -> pacotes = $pacotes; }else throw new TiroNaCara("TEM ALGO DE ERRADO COM OS MEUS PACOTES... SEU CRACKUDO FILHO DA PUTA!"); } public function comprarPedra($pedras){ if(is_numeric($pedras)){ $pacotes = $this -> pacotes; foreach($pacotes as $pedraDoPacote){ if($pedraDoPacote <= $pedras){ $resto = $pedras%$pedraDoPacote; if($resto) comprarPedra($resto); } } }else throw new TiroNaCara("TA ME TIRANDO, FILHO DA PUTA?!"); } } try{ $crack = new LojaDeCrack(array(20, 10, 7, '')); }catch(Exception $e){ echo $e -> getMessage(); } ?>
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.12 - 7.3.33, 7.4.0 - 7.4.33, 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: Call to undefined function checarPacotes() in /in/SCdDG:18 Stack trace: #0 /in/SCdDG(43): LojaDeCrack->__construct(Array) #1 {main} thrown in /in/SCdDG on line 18
Process exited with code 255.
Output for 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.28
Fatal error: Call to undefined function checarPacotes() in /in/SCdDG on line 18
Process exited with code 255.
Output for 5.1.0 - 5.1.6, 5.2.0 - 5.2.17
Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /in/SCdDG on line 18
Process exited with code 255.
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_FUNCTION, expecting ')' in /in/SCdDG on line 18
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SCdDG on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/SCdDG on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/SCdDG on line 3
Process exited with code 255.

preferences:
273.86 ms | 401 KiB | 356 Q