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.0040.01119.16
8.3.50.0070.01221.46
8.3.40.0130.00319.42
8.3.30.0120.00320.63
8.3.20.0030.00520.39
8.3.10.0040.00422.29
8.3.00.0080.00022.77
8.2.180.0000.02217.25
8.2.170.0130.01022.96
8.2.160.0070.01022.63
8.2.150.0000.00824.18
8.2.140.0060.00324.66
8.2.130.0040.00426.16
8.2.120.0040.00421.32
8.2.110.0090.00022.39
8.2.100.0090.00320.26
8.2.90.0080.00019.72
8.2.80.0000.00919.70
8.2.70.0030.00618.25
8.2.60.0000.00918.30
8.2.50.0030.00618.13
8.2.40.0080.00020.32
8.2.30.0040.00419.95
8.2.20.0000.00818.18
8.2.10.0000.00918.17
8.2.00.0000.00818.18
8.1.280.0170.00025.92
8.1.270.0030.00623.99
8.1.260.0080.00026.35
8.1.250.0110.00428.09
8.1.240.0060.00324.34
8.1.230.0040.00719.55
8.1.220.0060.00318.16
8.1.210.0060.00318.77
8.1.200.0070.00317.73
8.1.190.0000.00817.91
8.1.180.0000.00919.42
8.1.170.0060.00319.16
8.1.160.0060.00519.34
8.1.150.0030.00619.20
8.1.140.0030.00517.98
8.1.130.0040.00418.16
8.1.120.0060.00318.06
8.1.110.0040.00417.96
8.1.100.0030.00618.09
8.1.90.0040.00418.05
8.1.80.0000.00818.07
8.1.70.0060.00318.00
8.1.60.0040.00418.04
8.1.50.0030.00518.19
8.1.40.0000.00918.15
8.1.30.0000.00918.18
8.1.20.0030.00718.14
8.1.10.0030.00618.05
8.1.00.0030.00920.10
8.0.300.0000.00918.77
8.0.290.0060.00317.29
8.0.280.0040.00418.68
8.0.270.0000.00817.55
8.0.260.0070.00017.30
8.0.250.0030.00517.34
8.0.240.0080.00317.25
8.0.230.0000.00817.29
8.0.220.0000.00717.17
8.0.210.0040.00417.24
8.0.200.0000.00717.20
8.0.190.0000.00817.37
8.0.180.0040.00417.25
8.0.170.0040.00417.28
8.0.160.0040.00417.30
8.0.150.0040.00417.05
8.0.140.0080.00017.29
8.0.130.0000.00713.71
8.0.120.0030.00617.26
8.0.110.0030.00517.27
8.0.100.0030.00617.39
8.0.90.0040.00417.22
8.0.80.0030.01317.28
8.0.70.0060.00317.37
8.0.60.0030.00617.29
8.0.50.0050.00317.33
8.0.30.0140.00717.53
8.0.20.0060.01417.61
8.0.10.0050.00317.52
8.0.00.0150.01217.28
7.4.330.0040.00415.00
7.4.320.0000.00717.14
7.4.300.0000.00817.12
7.4.290.0000.00717.11
7.4.280.0050.00317.13
7.4.270.0070.00316.99
7.4.260.0070.00013.82
7.4.250.0030.00517.07
7.4.240.0030.00517.13
7.4.230.0000.00716.99
7.4.220.0130.00616.97
7.4.210.0070.01017.08
7.4.200.0080.00017.20
7.4.190.0000.00817.21
7.4.160.0050.01317.12
7.4.150.0100.01017.40
7.4.140.0150.00817.86
7.4.130.0110.00616.91
7.4.120.0100.00916.99
7.4.110.0030.02017.00
7.4.100.0040.01416.94
7.4.90.0130.00616.95
7.4.80.0120.01519.39
7.4.70.0070.01016.98
7.4.60.0140.00317.00
7.4.50.0060.00316.67
7.4.40.0070.01022.77
7.4.30.0090.00916.73
7.4.00.0050.01015.20
7.3.330.0000.00613.70
7.3.320.0000.00713.68
7.3.310.0040.00416.91
7.3.300.0050.00216.81
7.3.290.0070.00716.80
7.3.280.0050.01316.80
7.3.270.0150.00317.40
7.3.260.0090.01216.78
7.3.250.0110.01216.90
7.3.240.0170.00716.86
7.3.230.0130.00717.02
7.3.210.0120.00616.93
7.3.200.0060.01519.39
7.3.190.0090.01516.89
7.3.180.0100.00716.85
7.3.170.0070.01016.89
7.3.160.0100.01316.84
7.3.120.0070.00915.13
7.3.110.0060.01215.18
7.3.100.0070.00315.57
7.3.90.0090.00615.33
7.3.80.0060.00914.90
7.3.70.0060.00315.45
7.3.60.0070.01115.34
7.3.50.0030.00915.41
7.3.40.0060.01015.05
7.3.30.0030.01315.15
7.3.20.0060.00916.94
7.3.10.0090.00916.89
7.3.00.0070.00417.02
7.2.330.0080.01117.01
7.2.320.0120.01316.91
7.2.310.0110.01216.86
7.2.300.0130.00717.16
7.2.290.0140.00417.11
7.2.250.0120.00915.46
7.2.240.0140.00715.35
7.2.230.0030.00815.53
7.2.220.0060.00915.34
7.2.210.0000.01315.55
7.2.200.0030.01715.36
7.2.190.0160.00015.30
7.2.180.0000.01215.38
7.2.170.0110.00415.51
7.2.00.0130.00620.01
7.1.330.0000.01916.21
7.1.320.0080.00816.16
7.1.310.0140.00316.46
7.1.300.0040.01116.26
7.1.290.0000.01516.06
7.1.280.0070.00715.99
7.1.270.0060.01016.14
7.1.260.0030.01015.81
7.1.100.0040.01118.48
7.1.70.0090.00017.54
7.1.60.0100.01619.32
7.1.50.0030.01317.53
7.1.00.0100.04722.70
7.0.200.0000.01116.98
7.0.140.0070.07022.20
7.0.110.0200.06720.32
7.0.100.0230.07020.30
7.0.90.0130.07720.21
7.0.80.0130.04320.23
7.0.70.0200.05020.13
7.0.60.0070.08020.30
7.0.50.0070.07320.11
7.0.40.0100.04319.96
7.0.30.0130.05019.94
7.0.20.0070.06720.04
7.0.10.0030.04319.95
7.0.00.0030.08019.90
5.6.280.0030.07321.05
5.6.260.0030.03720.72
5.6.250.0100.08020.62
5.6.240.0100.03720.69
5.6.230.0070.08020.69
5.6.220.0130.07720.68
5.6.210.0070.08020.62
5.6.200.0100.06020.59
5.6.190.0070.06720.73
5.6.180.0170.04320.72
5.6.170.0070.04020.50
5.6.160.0100.06720.64
5.6.150.0070.04320.72
5.6.140.0170.04020.58
5.6.130.0030.07720.60
5.6.120.0100.07320.59
5.6.110.0030.05320.49
5.6.100.0030.04320.63
5.6.90.0070.08020.86
5.6.80.0100.04320.07
5.6.70.0130.07320.09
5.6.60.0070.07719.96
5.6.50.0030.04319.96
5.6.40.0000.05320.07
5.6.30.0130.07319.97
5.6.20.0070.07720.09
5.6.10.0070.04320.23
5.6.00.0000.08320.00
5.5.380.0070.07717.61
5.5.370.0070.07017.74
5.5.360.0100.07317.59
5.5.350.0070.04017.82
5.5.340.0130.07318.20
5.5.330.0130.04717.98
5.5.320.0030.04317.98
5.5.310.0030.04317.95
5.5.300.0070.07318.13
5.5.290.0000.07018.12
5.5.280.0070.07018.18
5.5.270.0070.04318.11
5.5.260.0070.05318.31
5.5.250.0070.07017.96
5.5.240.0030.07317.53
5.5.230.0100.07717.56
5.5.220.0100.04317.38
5.5.210.0030.04717.66
5.5.200.0130.04017.52
5.5.190.0100.07317.52
5.5.180.0000.05017.23
5.5.160.0100.07717.23
5.5.150.0100.07317.33
5.5.140.0100.06017.53
5.5.130.0070.06017.49
5.5.120.0030.04317.33
5.5.110.0070.06317.64
5.5.100.0030.05017.42
5.5.90.0170.05317.43
5.5.80.0030.06017.14
5.5.70.0030.05317.52
5.5.60.0000.08717.25
5.5.50.0100.06317.40
5.5.40.0070.06317.55
5.5.30.0030.06717.41
5.5.20.0130.03017.39
5.5.10.0100.03317.40
5.5.00.0100.07017.20
5.4.450.0070.08019.33
5.4.440.0000.04319.67
5.4.430.0000.06319.58
5.4.420.0030.07719.61
5.4.410.0070.07319.33
5.4.400.0030.06319.38
5.4.390.0100.05319.00
5.4.380.0070.07319.15
5.4.370.0100.04319.05
5.4.360.0100.05019.09
5.4.350.0030.04719.03
5.4.340.0030.06019.06
5.4.320.0070.07019.11
5.4.310.0070.04319.23
5.4.300.0170.07019.27
5.4.290.0170.06719.27
5.4.280.0070.04019.19
5.4.270.0070.04019.20
5.4.260.0100.07019.20
5.4.250.0100.06719.21
5.4.240.0200.06719.08
5.4.230.0030.05719.21
5.4.220.0030.07319.19
5.4.210.0200.06719.04
5.4.200.0100.06319.02
5.4.190.0130.05319.14
5.4.180.0100.06319.14
5.4.170.0100.07319.34
5.4.160.0170.06019.03
5.4.150.0070.04319.33
5.4.140.0100.06716.48
5.4.130.0070.03716.34
5.4.120.0000.05716.46
5.4.110.0100.03716.36
5.4.100.0100.07016.48
5.4.90.0000.04316.56
5.4.80.0130.06716.53
5.4.70.0170.06016.50
5.4.60.0130.03716.48
5.4.50.0100.03716.48
5.4.40.0070.07016.43
5.4.30.0070.07016.52
5.4.20.0130.06716.45
5.4.10.0070.06716.53
5.4.00.0130.03315.82
5.3.290.0070.06314.61
5.3.280.0100.07714.64
5.3.270.0070.03714.82
5.3.260.0100.08014.68
5.3.250.0130.04714.71
5.3.240.0100.07014.66
5.3.230.0100.03714.69
5.3.220.0000.04014.66
5.3.210.0100.07314.73
5.3.200.0100.06714.80
5.3.190.0070.06314.64
5.3.180.0100.07014.88
5.3.170.0070.03714.63
5.3.160.0030.07314.78
5.3.150.0100.07014.51
5.3.140.0030.04314.65
5.3.130.0070.07714.66
5.3.120.0070.07014.68
5.3.110.0100.06014.79
5.3.100.0170.05014.22
5.3.90.0070.07314.18
5.3.80.0070.07314.12
5.3.70.0100.07014.23
5.3.60.0130.04314.08
5.3.50.0070.06314.11
5.3.40.0030.07314.01
5.3.30.0170.02714.01
5.3.20.0170.06313.79
5.3.10.0030.07313.74
5.3.00.0130.06713.78
5.2.170.0130.05712.15
5.2.160.0000.05712.15
5.2.150.0030.03312.15
5.2.140.0100.05712.15
5.2.130.0030.05312.15
5.2.120.0000.06712.15
5.2.110.0170.02712.15
5.2.100.0030.03012.15
5.2.90.0170.03712.15
5.2.80.0130.05712.15
5.2.70.0030.04012.15
5.2.60.0030.06012.15
5.2.50.0130.05012.15
5.2.40.0000.03312.15
5.2.30.0070.06312.15
5.2.20.0070.05712.15
5.2.10.0070.05712.15
5.2.00.0000.04712.15
5.1.60.0130.04312.15
5.1.50.0030.04012.15
5.1.40.0030.05712.15
5.1.30.0070.04312.15
5.1.20.0070.04012.15
5.1.10.0000.03312.15
5.1.00.0030.03012.15
5.0.50.0030.02312.15
5.0.40.0030.04012.15
5.0.30.0030.05712.15
5.0.20.0100.03712.15
5.0.10.0030.02712.15
5.0.00.0030.03312.15
4.4.90.0000.03712.15
4.4.80.0000.02012.15
4.4.70.0000.02312.15
4.4.60.0000.03712.15
4.4.50.0030.01712.15
4.4.40.0030.04712.15
4.4.30.0070.01312.15
4.4.20.0000.01712.15
4.4.10.0000.03712.15
4.4.00.0000.02712.15
4.3.110.0000.03712.15
4.3.100.0030.03312.15
4.3.90.0030.03012.15
4.3.80.0000.05712.15
4.3.70.0030.03012.15
4.3.60.0030.03012.15
4.3.50.0000.03312.15
4.3.40.0100.04712.15
4.3.30.0070.02712.15
4.3.20.0000.03712.15
4.3.10.0000.03012.15
4.3.00.0000.03712.15

preferences:
40.81 ms | 401 KiB | 5 Q