3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Entity { private $name; public function __construct($name) { $this->name = $name; } public function getName() { return $this->name; } public function setName($name) { $this->name = $name; return $this; } } class DB { public function findByName($name) { if ($name === 'belette') { return new Entity($name); } return false; } } class Test { private $db; public function __construct(DB $db) { $this->db = $db; } public function getEntity($name) { $entity = $this->db->findByName($name); $new = false; if (false === $entity) { $entity = new Entity(); $entity->setName($name); $this->db->insert($entity); $new = true; } return new class($entity, $new) { private $new; public $entity; public function __construct(Entity $entity, $new) { $this->entity = $entity; $this->new = $new; } public function isNew() { return $this->new; } }; } } $db = new DB(); $test = new Test($db); $result = $test->getEntity('belette'); if ($result->isNew()) { echo "L'entité 'belette' n'existait pas en base\n"; } var_dump($result->entity);

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)
8.3.40.0070.01118.80
8.3.30.0110.00418.70
8.3.20.0080.00020.18
8.3.10.0030.00623.66
8.3.00.0050.00519.13
8.2.170.0140.01422.96
8.2.160.0070.00722.25
8.2.150.0030.00524.18
8.2.140.0080.00024.66
8.2.130.0040.00417.50
8.2.120.0040.00426.35
8.2.110.0060.00322.05
8.2.100.0100.00317.92
8.2.90.0030.00519.13
8.2.80.0000.00817.97
8.2.70.0050.00517.50
8.2.60.0060.00317.80
8.2.50.0090.00018.07
8.2.40.0000.00819.34
8.2.30.0040.00420.53
8.2.20.0040.00417.73
8.2.10.0040.00418.07
8.2.00.0040.00418.05
8.1.270.0070.00322.20
8.1.260.0000.00828.09
8.1.250.0070.00028.09
8.1.240.0060.00322.25
8.1.230.0100.00317.66
8.1.220.0040.00417.74
8.1.210.0040.00418.77
8.1.200.0030.00617.35
8.1.190.0080.00017.35
8.1.180.0030.00518.10
8.1.170.0030.00618.71
8.1.160.0000.00721.99
8.1.150.0040.00418.92
8.1.140.0060.00319.57
8.1.130.0000.00917.74
8.1.120.0030.00317.47
8.1.110.0060.00317.49
8.1.100.0060.00317.47
8.1.90.0040.00417.52
8.1.80.0050.00217.48
8.1.70.0000.00717.51
8.1.60.0040.00417.54
8.1.50.0030.00617.61
8.1.40.0080.00017.50
8.1.30.0090.00017.70
8.1.20.0060.00317.66
8.1.10.0080.00017.50
8.1.00.0000.00717.54
8.0.300.0040.00418.77
8.0.290.0040.00416.88
8.0.280.0040.00418.47
8.0.270.0000.00717.29
8.0.260.0000.00717.21
8.0.250.0000.00917.04
8.0.240.0030.00617.01
8.0.230.0070.00017.04
8.0.220.0100.00016.96
8.0.210.0000.00816.90
8.0.200.0000.00616.96
8.0.190.0030.00516.96
8.0.180.0040.00417.02
8.0.170.0040.00417.03
8.0.160.0050.00316.96
8.0.150.0000.00816.88
8.0.140.0090.00016.94
8.0.130.0030.00313.50
8.0.120.0090.00017.00
8.0.110.0070.00017.03
8.0.100.0040.00416.78
8.0.90.0040.00416.95
8.0.80.0090.00616.98
8.0.70.0060.00317.05
8.0.60.0040.00416.81
8.0.50.0000.00716.80
8.0.30.0100.00716.98
8.0.20.0090.00817.40
8.0.10.0000.00716.91
8.0.00.0110.00816.84
7.4.330.0000.00516.76
7.4.320.0030.00316.62
7.4.300.0070.00016.39
7.4.290.0040.00416.48
7.4.280.0030.00516.61
7.4.270.0000.00716.65
7.4.260.0070.00016.52
7.4.250.0040.00416.52
7.4.240.0040.00416.58
7.4.230.0000.00716.57
7.4.220.0100.01616.65
7.4.210.0040.01016.58
7.4.200.0050.00316.33
7.4.160.0120.00316.55
7.4.150.0120.00417.40
7.4.140.0120.01217.86
7.4.130.0060.01616.54
7.4.120.0130.00616.48
7.4.110.0070.01016.53
7.4.100.0110.01116.46
7.4.90.0040.01316.61
7.4.80.0070.01019.39
7.4.70.0100.01116.60
7.4.60.0060.00916.45
7.4.50.0070.00716.38
7.4.40.0080.00816.74
7.4.30.0120.00616.65
7.4.00.0040.01115.15
7.3.330.0050.00013.30
7.3.320.0000.00613.31
7.3.310.0070.00016.21
7.3.300.0040.00416.33
7.3.290.0050.00316.20
7.3.280.0110.00616.32
7.3.270.0160.00917.40
7.3.260.0070.01116.60
7.3.250.0070.01016.44
7.3.240.0080.01016.55
7.3.230.0130.01016.50
7.3.210.0140.00416.64
7.3.200.0140.00316.62
7.3.190.0140.00316.27
7.3.180.0150.00516.42
7.3.170.0070.01416.38
7.3.160.0090.00616.52
7.2.330.0100.00716.83
7.2.320.0030.01316.71
7.2.310.0030.01416.77
7.2.300.0130.00516.47
7.2.290.0160.00716.72
7.2.60.0140.00315.70
7.2.00.0030.01019.63
7.1.200.0040.00715.80
7.1.100.0040.00717.89
7.1.70.0000.01016.98
7.1.60.0130.01319.48
7.1.50.0030.01316.93
7.1.00.0000.08022.30
7.0.200.1160.00714.37
7.0.60.0030.08320.05
7.0.50.0070.05717.87
7.0.40.0070.05320.27
7.0.30.0300.08720.23
7.0.20.0300.04320.19
7.0.10.0070.06020.15
7.0.00.0070.04020.30
5.6.280.0070.06721.11
5.6.210.0030.04320.73
5.6.200.0030.04318.19
5.6.190.0000.04320.41
5.6.180.0500.04720.61
5.6.170.0370.07720.46
5.6.160.0130.07320.39
5.6.150.0030.08018.18
5.6.140.0030.06018.18
5.6.130.0100.07718.16
5.6.120.0030.07021.04
5.6.110.0030.08720.99
5.6.100.0070.07721.03
5.6.90.0070.03720.91
5.6.80.0030.04020.43
5.5.350.3500.04320.45
5.5.340.0100.03717.99
5.5.330.0100.08020.27
5.5.320.0400.03720.20
5.5.310.0270.04320.31
5.5.300.0100.07718.08
5.5.290.0070.07018.04
5.5.280.0130.07720.91
5.5.270.0100.05320.77
5.5.260.0030.04720.74
5.5.250.0130.08020.59
5.5.240.0270.06720.27

preferences:
43.88 ms | 400 KiB | 5 Q