3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Person { public $name = 'Jackie'; public $job = 'PHP Developer'; } // Create instance $person = new Person(); $property = ['first' => 'name', 'second' => 'job']; echo "\nMy name is " . $person->{$property['first']} . "\n"; echo "\nMy job is " . $person->$property['second'] . "\n";
Output for 8.3.0 - 8.3.7
My name is Jackie Warning: Array to string conversion in /in/EtpIU on line 13 Warning: Undefined property: Person::$Array in /in/EtpIU on line 13 Warning: Trying to access array offset on null in /in/EtpIU on line 13 My job is
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19
My name is Jackie Warning: Array to string conversion in /in/EtpIU on line 13 Warning: Undefined property: Person::$Array in /in/EtpIU on line 13 Warning: Trying to access array offset on value of type null in /in/EtpIU on line 13 My job is
Output for 7.4.0 - 7.4.33
My name is Jackie Notice: Array to string conversion in /in/EtpIU on line 13 Notice: Undefined property: Person::$Array in /in/EtpIU on line 13 Notice: Trying to access array offset on value of type null in /in/EtpIU on line 13 My job is
Output for 7.3.32 - 7.3.33
My name is Jackie My job is
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31
My name is Jackie Notice: Array to string conversion in /in/EtpIU on line 13 Notice: Undefined property: Person::$Array in /in/EtpIU on line 13 My job is
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.21
My name is Jackie My job is PHP Developer

preferences:
154.96 ms | 402 KiB | 227 Q