3v4l.org

run code in 300+ PHP versions simultaneously
<?php class DataObjectSecurityException extends Exception {}; abstract class DataObject { private $key; public function __construct(array $fields, string $key) { foreach($fields as $field => $value) { $this->$field = $value; } $this->key = $key; } public function export(string $key) { if ($key !== $this->key) { throw new DataObjectSecurityException("you are not authorized"); } return get_object_vars($this); } } class User extends DataObject { protected $id; protected $name; protected $hairColor; public function hi() { echo "Hi {$this->name}. You have nice {$this->hairColor} hair." . PHP_EOL; } public function dyeHair(string $color) { $this->hairColor = $color; } } // sample data as would be extracted from DB: $userData = ['id' => 11, 'name' => 'Jane Doe', 'hairColor' => 'brown']; $key = uniqid(); $user = new User($userData, $key); $user->hi(); echo "changing hair color" . PHP_EOL; $user->dyeHair('blue'); $user->hi(); // now retrieve the data if we want to update the DB $newUserData = $user->export($key); echo "new user data:" . PHP_EOL; var_dump($newUserData);

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.4.10.0030.01414.80
7.4.00.0100.00714.55
7.3.130.0060.01214.76
7.3.120.0070.01015.09
7.3.110.0110.00414.90
7.3.100.0070.00715.03
7.3.90.0100.00715.05
7.3.80.0070.00715.18
7.3.70.0070.00714.61
7.3.60.0070.00714.96
7.3.50.0000.01414.80
7.3.40.0070.00414.56
7.3.30.0090.00314.76
7.3.20.0120.00016.73
7.3.10.0070.01016.56
7.3.00.0050.00916.69
7.2.260.0070.01315.32
7.2.250.0090.00915.20
7.2.240.0060.01015.12
7.2.230.0040.00715.12
7.2.220.0090.00914.91
7.2.210.0060.00615.03
7.2.200.0030.01015.10
7.2.190.0060.00315.12
7.2.180.0090.00314.93
7.2.170.0000.00915.21
7.2.160.0040.01215.31
7.2.150.0120.00316.72
7.2.140.0080.00316.86
7.2.130.0120.00216.89
7.2.120.0030.01016.83
7.2.110.0060.00816.85
7.2.100.1140.00616.14
7.2.90.1420.01016.17
7.2.80.1050.01216.08
7.2.70.1710.00716.25
7.2.60.1190.00716.10
7.2.50.1660.00716.22
7.2.40.1550.00916.34
7.2.30.0860.00716.28
7.2.20.1130.00916.22
7.2.10.1140.00716.36
7.2.00.0800.00816.28
7.1.330.0030.01315.86
7.1.320.0070.01015.57
7.1.310.0070.01016.01
7.1.300.0000.01215.61
7.1.290.0040.00715.89
7.1.280.0060.00615.92
7.1.270.0060.00815.77
7.1.260.0080.00615.82
7.1.250.0030.01115.86
7.1.240.0070.00615.62
7.1.230.0080.00815.79
7.1.220.1680.01014.92
7.1.210.1260.00615.00
7.1.200.1880.01015.20
7.1.190.0090.01015.02
7.1.180.1430.00615.03
7.1.170.1560.00915.22
7.1.160.1470.00915.17
7.1.150.1220.00615.11
7.1.140.1260.00715.21
7.1.130.0880.01015.18
7.1.120.0950.00715.21
7.1.110.1250.01015.30
7.1.100.1170.00715.17
7.1.90.0060.00915.01
7.1.80.0090.00515.09
7.1.70.0110.00714.99
7.1.60.1360.01021.09
7.1.50.0310.01121.01
7.1.40.0350.00220.97
7.1.30.0180.00821.03
7.1.20.0500.00621.19
7.1.10.0270.00915.11
7.1.00.0070.00715.14
7.0.330.0140.00215.38
7.0.320.0000.01515.18
7.0.310.0080.00415.45
7.0.300.0030.00715.51
7.0.290.0070.00715.64
7.0.280.0000.01515.57
7.0.270.0080.00515.56
7.0.260.0100.00715.44
7.0.250.0070.00715.29
7.0.240.0030.01015.34
7.0.230.0060.01015.64
7.0.220.0000.01315.52
7.0.210.0040.00715.50
7.0.200.0080.00815.48
7.0.190.0070.00415.52
7.0.180.0040.01215.58
7.0.170.0000.01515.47
7.0.160.0030.01415.11
7.0.150.0030.01015.36
7.0.140.0030.00815.45
7.0.130.0060.00915.52
7.0.120.0100.00715.52
7.0.110.0060.00615.46
7.0.100.0040.01115.19
7.0.90.0120.00415.32
7.0.80.0070.01015.58
7.0.70.0090.00615.51
7.0.60.0040.01115.58
7.0.50.0030.01015.50
7.0.40.0000.01113.38
7.0.30.0030.01013.55
7.0.20.0060.00613.42
7.0.10.0040.01113.60
7.0.00.0000.01413.55
5.6.400.0040.00814.38
5.6.390.0030.00714.13
5.6.380.0090.00714.12
5.6.370.0060.00614.49
5.6.360.0060.00614.38
5.6.350.0030.00914.08
5.6.340.0070.00714.58
5.6.330.0060.00314.39
5.6.320.0100.00414.46
5.6.310.0000.01514.69
5.6.300.0040.00814.20
5.6.290.0030.00614.63
5.6.280.0060.00914.35
5.6.270.0030.00914.02
5.6.260.0040.00714.44
5.6.250.0070.00714.62
5.6.240.0120.00314.23
5.6.230.0080.00414.21
5.6.220.0140.00314.59
5.6.210.0080.00814.19
5.6.200.0030.01014.55
5.6.190.0050.00514.17
5.6.180.0080.00814.49
5.6.170.0040.01214.27
5.6.160.0030.01014.18
5.6.150.0060.00614.18
5.6.140.0000.01114.20
5.6.130.0100.00314.14
5.6.120.0040.01414.48
5.6.110.0030.01414.29
5.6.100.0000.01514.39
5.6.90.0040.01214.32
5.6.80.0060.00914.31
5.6.70.0030.00614.49
5.6.60.0080.00314.15
5.6.50.0030.00714.03
5.6.40.0000.01114.29
5.6.30.0040.00414.01
5.6.20.0000.00914.34
5.6.10.0000.01114.23
5.6.00.0000.01714.23

preferences:
31.4 ms | 401 KiB | 5 Q