3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arg = 'Y'; $vehicle = ( ( $arg == 'B' ) ? 'bus' : ( $arg == 'A' ) ? 'airplane' : ( $arg == 'I' ) ? 'train' : ( $arg == 'C' ) ? 'car' : ( $arg == 'I' ) ? 'horse' : 'feet' ); echo $vehicle; $vehicle2 = array( "B" => "bus", "A" => "airplane", "T" => "train", "C" => "car", "H" => "hourse", "default" => "feet" ); $vehicle2->setDefault(6); echo $vehicle2[$arg];
Output for 7.0.0 - 7.1.0
feet Fatal error: Uncaught Error: Call to a member function setDefault() on array in /in/IOT1q:19 Stack trace: #0 {main} thrown in /in/IOT1q on line 19
Process exited with code 255.
Output for 5.6.0 - 5.6.28
feet Fatal error: Call to a member function setDefault() on array in /in/IOT1q on line 19
Process exited with code 255.
Output for 5.0.0 - 5.5.38
feet Fatal error: Call to a member function setDefault() on a non-object in /in/IOT1q on line 19
Process exited with code 255.
Output for 4.3.2 - 4.4.9
feet Fatal error: Call to a member function on a non-object in /in/IOT1q on line 19
Process exited with code 255.
Output for 4.3.0 - 4.3.1
feet Fatal error: Call to a member function on a non-object in /in/IOT1q on line 19