3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php class Carro { protected $productos = array (); public add ( $producto, $cantidad ) { this->productos[$producto] = $cantidad; } public what_inside_cart () { $callback = function ( $producto ) { return $producto; } array_walk ( $this->productos, $callback ); } } $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 ();
Output for 5.4.0 - 5.4.23
Parse error: syntax error, unexpected 'add' (T_STRING), expecting variable (T_VARIABLE) in /in/ElvFd on line 7
Process exited with code 255.
Output for 5.3.0 - 5.3.28
Parse error: syntax error, unexpected T_STRING, expecting T_VARIABLE in /in/ElvFd on line 7
Process exited with code 255.