3v4l.org

run code in 300+ PHP versions simultaneously
<?php class UserModel { public $name = null, $occupation = null, $email = null, $oldname = null, $oldoccupation = null, $oldemail = null, $me, $handler, $result; public function __construct(){ } public function create($fields = array()){ if(count($fields) == 3){ $this->name = $fields['name']; $this->occupation = $fields['occupation']; $this->email = $fields['email']; } } public function _save(){ if($this->oldname == null && $this->oldoccupation == null && $this->oldemail == null){ $sql = "INSERT INTO users (name, occupation, email) VALUES ('".$this->name."', '".$this->occupation."', '".$this->email."')"; /*$this->result = $this->handler->prepare($sql); /$this->result->execute(array( ':name'=>$this->name, ':occupation'=>$this->occupation, ':email'=>$this->email ));*/ echo $sql; } else { $sql = "UPDATE users SET name = '".$this->name."', occupation = '".$this->occupation."', email = '".$this->email."' WHERE name = '".$this->oldname."'"; /*$this->result = $this->handler->prepare($sql); $this->result->execute(array( ':name'=>$this->name, ':occupation'=>$this->occupation, ':email'=>$this->email, ':oldname'=>$this->oldname ));*/ echo $sql; } } public function name($given_name = null) { if($this->name == null){ if($given_name != null){ $this->name = $given_name; } } else { if($given_name != null){ $this->oldname = $this->name; $this->name = $given_name; } } return $this->name; } public function occupation($given_occupation = null) { if($this->occupation == null){ if($given_occupation != null){ $this->occupation = $given_occupation; } } else { if($given_occupation != null){ $this->oldoccupation = $this->occupation; $this->occupation = $given_occupation; } } return $this->occupation; } public function email($given_email = null){ $this->verifyEmail($given_email); if($given_email != null){ // $this->oldemail = $this->email; // THIS LINE IS THE ISSUE $this->email = $given_email; } return $this->email; } public function verifyEmail($givenemail = null){ if($givenemail == null){ $email = $this->email; } else { $email = $givenemail; } if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { throw new Exception('Email not valid.'); die(); } } } $user = new UserModel(); $user->create(array( 'name' => 'Luke', 'occupation' => 'Programmer', 'email' => 'luke@gmail.com' )); $user->_save(); $user->name('Jack'); $user->occupation(); try { $user->email('demo@example.co.za'); } catch (Exception $e) { echo $e->getMessage(); } $user->_save();

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.60.0160.00617.13
8.3.50.0150.00722.19
8.3.40.0070.01719.59
8.3.30.0000.01519.59
8.3.20.0030.00520.71
8.3.10.0090.00024.03
8.3.00.0060.00321.32
8.2.180.0100.01316.85
8.2.170.0160.00022.96
8.2.160.0090.00620.82
8.2.150.0040.00424.18
8.2.140.0080.00024.66
8.2.130.0040.00426.16
8.2.120.0030.00619.73
8.2.110.0100.00021.55
8.2.100.0110.00018.53
8.2.90.0000.00919.67
8.2.80.0030.00618.13
8.2.70.0060.00317.99
8.2.60.0040.00918.16
8.2.50.0060.00318.25
8.2.40.0000.00818.78
8.2.30.0030.00718.70
8.2.20.0090.00018.32
8.2.10.0000.00818.44
8.2.00.0030.00519.93
8.1.280.0100.00625.92
8.1.270.0090.00024.30
8.1.260.0030.00526.35
8.1.250.0040.00428.09
8.1.240.0000.01021.69
8.1.230.0100.00318.20
8.1.220.0060.00318.18
8.1.210.0060.00318.77
8.1.200.0030.00717.85
8.1.190.0060.00317.73
8.1.180.0080.00018.10
8.1.170.0060.00319.13
8.1.160.0040.00422.48
8.1.150.0040.00419.34
8.1.140.0040.00418.11
8.1.130.0030.00518.18
8.1.120.0000.00818.09
8.1.110.0030.00617.94
8.1.100.0080.00018.05
8.1.90.0050.00218.05
8.1.80.0000.00818.06
8.1.70.0040.00417.98
8.1.60.0090.00018.19
8.1.50.0090.00018.01
8.1.40.0000.00817.98
8.1.30.0040.00418.24
8.1.20.0030.00518.20
8.1.10.0050.00518.23
8.1.00.0030.00920.10
8.0.300.0030.00618.77
8.0.290.0080.00017.25
8.0.280.0040.00418.70
8.0.270.0020.00517.55
8.0.260.0040.00417.50
8.0.250.0000.00717.36
8.0.240.0050.00317.38
8.0.230.0050.00317.28
8.0.220.0050.00317.38
8.0.210.0000.00717.24
8.0.200.0000.00717.30
8.0.190.0000.00817.34
8.0.180.0090.00317.23
8.0.170.0060.00317.25
8.0.160.0030.00517.14
8.0.150.0030.00517.21
8.0.140.0000.00917.11
8.0.130.0030.00313.68
8.0.120.0030.00617.20
8.0.110.0000.00817.38
8.0.100.0030.00517.13
8.0.90.0090.00017.23
8.0.80.0120.01217.37
8.0.70.0080.00017.27
8.0.60.0040.00417.37
8.0.50.0080.00017.38
8.0.30.0120.00717.52
8.0.20.0080.01217.62
8.0.10.0030.00617.46
8.0.00.0080.01417.28
7.4.330.0060.00015.32
7.4.320.0030.00317.14
7.4.300.0030.00317.01
7.4.290.0060.00317.00
7.4.280.0000.00916.91
7.4.270.0070.00016.93
7.4.260.0040.00417.09
7.4.250.0000.00816.98
7.4.240.0000.00817.07
7.4.230.0000.00817.09
7.4.220.0070.01117.18
7.4.210.0150.00317.14
7.4.200.0040.00416.91
7.4.160.0060.01217.02
7.4.150.0120.00917.40
7.4.140.0080.01117.86
7.4.130.0110.00816.94
7.4.120.0110.00816.92
7.4.110.0050.01617.02
7.4.100.0050.01417.03
7.4.90.0130.00716.79
7.4.80.0040.01419.39
7.4.70.0070.01116.96
7.4.60.0030.01417.03
7.4.50.0040.00416.86
7.4.40.0160.00316.88
7.4.30.0120.01216.83
7.4.00.0140.00415.30
7.3.330.0030.00313.81
7.3.320.0000.00613.74
7.3.310.0070.00016.65
7.3.300.0000.00716.85
7.3.290.0180.00616.73
7.3.280.0130.00816.82
7.3.270.0030.01517.40
7.3.260.0120.00916.72
7.3.250.0120.00716.97
7.3.240.0170.00317.01
7.3.230.0060.01116.74
7.3.210.0090.01016.94
7.3.200.0060.01719.39
7.3.190.0170.00717.00
7.3.180.0060.01016.78
7.3.170.0080.01016.71
7.3.160.0140.00516.76
7.3.120.0080.00815.34
7.2.330.0060.01316.95
7.2.320.0120.00617.03
7.2.310.0120.00617.09
7.2.300.0040.01417.12
7.2.290.0060.01316.93
7.2.60.0000.01217.25
7.1.200.0040.01116.14
7.1.70.0000.00817.52
7.1.60.0180.00619.70
7.1.50.0220.00317.46
7.1.00.0100.07322.64
7.0.200.0000.01117.28
7.0.140.0130.06022.18
7.0.70.0030.07720.27
7.0.60.0070.09020.25
7.0.50.0230.05020.55
7.0.40.0170.04320.37
7.0.30.0070.05320.35
7.0.20.0000.07320.35
7.0.10.0030.05720.20
7.0.00.0070.08720.29
5.6.280.0170.06021.11
5.6.220.0000.09020.63
5.6.210.0130.05720.75
5.6.200.0030.08321.13
5.6.190.0100.07721.08
5.6.180.0170.07721.16
5.6.170.0130.07321.05
5.6.160.0100.08721.13
5.6.150.0070.06021.06
5.6.140.0130.08021.00
5.6.130.0200.07721.12
5.6.120.0130.04721.01
5.6.110.0030.07020.99
5.6.100.0070.08721.07
5.6.90.0070.08321.04
5.6.80.0000.05720.53
5.6.70.0070.04320.59
5.6.60.0070.08020.50
5.6.50.0070.05020.36
5.6.40.0030.08720.51
5.6.30.0030.08320.36
5.6.20.0100.07320.36
5.6.10.0030.08320.33
5.6.00.0130.08020.36
5.5.360.0030.08320.38
5.5.350.0100.09020.38
5.5.340.0100.08720.96
5.5.330.0030.06320.91
5.5.320.0030.06320.90
5.5.310.0070.06020.96
5.5.300.0070.08720.81
5.5.290.0170.08020.90
5.5.280.0070.05020.96
5.5.270.0070.04320.86
5.5.260.0000.07320.68
5.5.250.0030.05020.65
5.5.240.0030.05720.23
5.5.230.0100.06720.34
5.5.220.0100.07320.25
5.5.210.0070.06320.26
5.5.200.0100.07320.13
5.5.190.0030.08720.32
5.5.180.0030.08720.29
5.5.160.0130.06720.17
5.5.150.0100.05320.28
5.5.140.0030.08020.30
5.5.130.0130.08320.26
5.5.120.0030.08320.12
5.5.110.0100.08020.16
5.5.100.0130.07320.09
5.5.90.0100.06320.05
5.5.80.0130.07020.10
5.5.70.0070.07320.20
5.5.60.0200.05019.98
5.5.50.0070.07020.11
5.5.40.0100.05020.10
5.5.30.0030.08720.18
5.5.20.0070.08020.14
5.5.10.0100.08020.09
5.5.00.0130.07020.09
5.4.450.0070.08019.41
5.4.440.0130.07719.22
5.4.430.0070.04319.60
5.4.420.0030.05019.25
5.4.410.0030.07719.34
5.4.400.0030.07718.96
5.4.390.0070.08018.96
5.4.380.0130.07018.93
5.4.370.0130.05318.90
5.4.360.0130.06718.96
5.4.350.0070.08018.93
5.4.340.0000.08719.27
5.4.320.0100.07318.96
5.4.310.0030.06719.21
5.4.300.0030.07019.18
5.4.290.0200.06719.08
5.4.280.0030.08319.08
5.4.270.0230.05318.96
5.4.260.0030.07018.95
5.4.250.0070.07319.25
5.4.240.0130.04319.25
5.4.230.0100.04319.09
5.4.220.0030.06319.10
5.4.210.0070.08019.21
5.4.200.0170.06719.15
5.4.190.0130.04319.22
5.4.180.0030.07718.99
5.4.170.0030.08318.92
5.4.160.0200.06019.24
5.4.150.0200.06719.06
5.4.140.0130.05316.42
5.4.130.0100.07016.45
5.4.120.0030.07716.25
5.4.110.0070.06016.45
5.4.100.0000.08016.38
5.4.90.0070.07016.37
5.4.80.0070.05316.33
5.4.70.0000.08016.35
5.4.60.0070.04316.32
5.4.50.0000.06716.26
5.4.40.0070.06716.51
5.4.30.0170.04016.44
5.4.20.0000.05716.27
5.4.10.0070.07716.45
5.4.00.0170.06015.91
5.3.290.0070.07315.79
5.3.280.0070.06715.79
5.3.270.0100.04315.79
5.3.260.0030.08015.79
5.3.250.0070.04015.79
5.3.240.0030.08015.79
5.3.230.0100.07715.79
5.3.220.0070.07015.79
5.3.210.0030.08715.79
5.3.200.0070.06715.79
5.3.190.0100.06315.79
5.3.180.0170.06315.79
5.3.170.0130.06315.79
5.3.160.0100.07015.79
5.3.150.0100.06715.79
5.3.140.0030.08015.79
5.3.130.0070.07015.79
5.3.120.0070.05015.79
5.3.110.0030.06315.79
5.3.100.0130.06715.79
5.3.90.0030.07315.79
5.3.80.0000.06715.79
5.3.70.0070.04015.79
5.3.60.0000.08715.79
5.3.50.0070.07315.79
5.3.40.0030.08015.79
5.3.30.0070.03315.79
5.3.20.0100.06315.79
5.3.10.0030.05315.79
5.3.00.0100.05315.79
5.2.170.0000.06315.79
5.2.160.0030.06315.79
5.2.150.0070.04715.79
5.2.140.0000.03315.79
5.2.130.0130.05315.79
5.2.120.0100.06015.79
5.2.110.0100.06015.79
5.2.100.0000.06715.79
5.2.90.0070.06315.79
5.2.80.0000.06715.79
5.2.70.0100.05715.79
5.2.60.0100.05315.79
5.2.50.0070.06315.79
5.2.40.0070.06015.79
5.2.30.0070.06015.79
5.2.20.0100.03015.79
5.2.10.0030.05015.79
5.2.00.0030.06715.79
5.1.60.0000.06015.79
5.1.50.0000.05715.79
5.1.40.0000.05315.79
5.1.30.0100.05315.79
5.1.20.0070.04715.79
5.1.10.0070.05315.79
5.1.00.0030.05315.79
5.0.50.0100.04015.79
5.0.40.0000.03315.79
5.0.30.0030.05315.79
5.0.20.0070.03715.79
5.0.10.0070.04315.79
5.0.00.0070.06015.79
4.4.90.0030.03015.79
4.4.80.0070.03015.79
4.4.70.0000.02315.79
4.4.60.0000.02715.79
4.4.50.0030.02015.79
4.4.40.0070.05015.79
4.4.30.0000.03715.79
4.4.20.0030.01715.79
4.4.10.0000.04015.79
4.4.00.0000.05715.79
4.3.110.0000.03015.79
4.3.100.0000.02715.79
4.3.90.0100.02015.79
4.3.80.0030.05315.79
4.3.70.0000.02015.79
4.3.60.0000.01715.79
4.3.50.0070.03315.79
4.3.40.0000.04015.79
4.3.30.0000.01715.79
4.3.20.0000.01715.79
4.3.10.0000.01715.79
4.3.00.0100.02715.79

preferences:
47.46 ms | 401 KiB | 5 Q