3v4l.org

run code in 300+ PHP versions simultaneously
<?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');

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
7.2.70.0250.00314.63
7.2.60.0140.00914.85
7.2.50.0220.00314.79
7.2.40.0220.00614.75
7.2.30.0130.01014.51
7.2.20.0150.00914.83
7.2.10.0150.00914.76
7.2.00.0140.00714.64
7.1.170.0190.00613.54
7.1.160.0200.00713.52
7.1.150.0180.00913.75
7.1.140.0170.01013.70
7.1.130.0110.00913.59
7.1.120.0110.01113.72
7.1.110.0210.00313.84
7.1.100.0920.01013.50
7.1.90.0130.00713.50
7.1.80.0070.01313.48
7.1.70.0280.00313.29
7.1.60.0320.00631.55
7.1.50.0490.00631.43
7.1.40.0440.00631.63
7.1.30.0400.00731.52
7.1.20.0450.00731.55
7.1.10.0130.01513.29
7.1.00.0100.01013.57

preferences:
141.4 ms | 1394 KiB | 7 Q