3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php class Carro { protected $productos = array (); public function add ( $producto, $cantidad ) { $this->productos[$producto] = $cantidad; } public function what_inside_cart () { $cadena = ""; $callback = function ( $producto, $cantidad ) { $cadena += $producto . "\r\n"; } //array_walk ( $this->productos, $callback ); return $cadena; } } $mi_carro = new Carro; // Añadir algunos artículos al carro $mi_carro->añadir('mantequilla', 1); $mi_carro->añadir('leche', 3); $mi_carro->añadir('huevos', 6); //echo $mi_carro->what_inside_cart (); echo $mi_carro[0];
Output for 5.4.0 - 5.4.23
Parse error: syntax error, unexpected 'return' (T_RETURN) in /in/Z4mrn on line 22
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_RETURN in /in/Z4mrn on line 22
Process exited with code 255.