3v4l.org

run code in 300+ PHP versions simultaneously
<?php lass Person { public static $company = 'TechBase VietNam'; public function getFriends() { return [ 'John' => function () { return 'John is my best friend!'; }, 'Alan' => function () { return 'Alan is old friend!'; } ]; } public function getFriendOf($someone) { return $this->getFriends()[$someone]; } public static function getNewPerson() { return new Person(); } } // Create instance $person = new Person(); // Get friend echo "\n" . $person->getFriends()['John'] . "\n"; echo "\n" . $person->getFriends('Alan') . "\n"; // Get company echo "\n" . $person::getNewPerson()::$company . "\n";
Output for 5.5.24 - 5.5.30, 5.6.8 - 5.6.16, 7.0.0
Parse error: syntax error, unexpected 'Person' (T_STRING) in /in/Vab03 on line 2
Process exited with code 255.

preferences:
168.27 ms | 1395 KiB | 24 Q