3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php //class Car //{ // public $color; // public $type; //} //$myCar = new Car(); $myCar->color = 'red'; $myCar->type = 'sedan'; //$yourCar = new Car(); $yourCar->color = 'blue'; $yourCar->type = 'suv'; $cars = array($myCar, $yourCar); print_r($cars); foreach ($cars as $car) { echo 'This car is a ' . $car->color . ' ' . $car->type . "\n"; } ?>
based on QivlZ
Output for 5.4.0 - 7.2.0
Warning: Creating default object from empty value in /in/L9Zbp on line 11 Warning: Creating default object from empty value in /in/L9Zbp on line 15 Array ( [0] => stdClass Object ( [color] => red [type] => sedan ) [1] => stdClass Object ( [color] => blue [type] => suv ) ) This car is a red sedan This car is a blue suv
Output for 5.0.0 - 5.3.29
Strict Standards: Creating default object from empty value in /in/L9Zbp on line 11 Strict Standards: Creating default object from empty value in /in/L9Zbp on line 15 Array ( [0] => stdClass Object ( [color] => red [type] => sedan ) [1] => stdClass Object ( [color] => blue [type] => suv ) ) This car is a red sedan This car is a blue suv
Output for 4.3.0 - 4.4.9
Array ( [0] => stdClass Object ( [color] => red [type] => sedan ) [1] => stdClass Object ( [color] => blue [type] => suv ) ) This car is a red sedan This car is a blue suv