3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $PDO = new PDO('sqlite::memory:', null, null, [PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION]); $PDO->exec('create table users(name text)'); $PDO->exec("insert into users values('alice'), ('bob')"); $user = $PDO->query('select name from users limit 1')->fetchObject(User::class); echo "Hello, {$user->getName()}!"; class User { protected $name; public function getName() : string { return $this->name; } }
based on XNNm4
Output for 7.0.0 - 7.3.0beta1
Hello, alice!
Output for 5.6.0 - 5.6.29
Parse error: syntax error, unexpected ':', expecting ';' or '{' in /in/NOLVd on line 13
Process exited with code 255.