3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php use PDO; class Role { private $db; private $userId; public function __construct(PDO $db, $userId) { $this->db = $db; $this->userId = $userId; } public function hasPermission($permissionName) { $sql = $this->db->prepare(' SELECT p.name FROM users INNER JOIN user_product u on users.id = u.user_id INNER JOIN products p on u.product_id = p.id WHERE users.id = ? '); $sql->execute([$this->userId]); $results = $sql->fetchAll(PDO::FETCH_COLUMN); if (in_array($permissionName, $results)) { return true; } return false; } } Then used by: $role = new Role($auth->userId); $role->hasPermission('foo');
Output for 7.0.30 - 7.3.0alpha1
Parse error: syntax error, unexpected 'used' (T_STRING) in /in/sRhIJ on line 36
Process exited with code 255.
Output for hhvm-3.22.0
Fatal error: Uncaught Error: syntax error, unexpected T_STRING in /in/sRhIJ:-1 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.18.5 - 3.21.3
Fatal error: Uncaught Error: syntax error, unexpected T_STRING in /in/sRhIJ:36 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.30
Warning: The use statement with non-compound name 'PDO' has no effect in /in/sRhIJ on line 3 Parse error: syntax error, unexpected 'used' (T_STRING) in /in/sRhIJ on line 36
Process exited with code 255.