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.0070.00718.80
8.3.50.0120.00722.24
8.3.40.0100.01019.29
8.3.30.0060.00920.68
8.3.20.0000.00820.59
8.3.10.0040.00422.52
8.3.00.0090.00022.90
8.2.180.0090.00617.38
8.2.170.0060.00922.96
8.2.160.0070.00722.46
8.2.150.0080.00024.18
8.2.140.0060.00324.66
8.2.130.0060.00326.16
8.2.120.0080.00021.19
8.2.110.0060.00322.66
8.2.100.0100.00318.47
8.2.90.0060.00318.38
8.2.80.0030.00618.43
8.2.70.0030.00618.30
8.2.60.0060.00318.28
8.2.50.0030.00618.18
8.2.40.0040.00420.95
8.2.30.0000.00819.82
8.2.20.0000.00818.11
8.2.10.0000.00918.24
8.2.00.0030.00518.16
8.1.270.0080.00024.27
8.1.260.0050.00526.35
8.1.250.0060.00328.09
8.1.240.0060.00322.52
8.1.230.0070.00719.31
8.1.220.0030.00618.16
8.1.210.0030.00618.77
8.1.200.0050.00517.98
8.1.190.0000.01217.85
8.1.180.0090.00018.10
8.1.170.0040.00419.09
8.1.160.0080.00319.38
8.1.150.0080.00019.28
8.1.140.0030.00618.09
8.1.130.0040.00418.10
8.1.120.0080.00417.96
8.1.110.0050.00317.91
8.1.100.0000.00817.93
8.1.90.0030.00518.08
8.1.80.0000.00818.05
8.1.70.0050.00217.97
8.1.60.0000.00818.16
8.1.50.0030.00518.10
8.1.40.0060.00318.11
8.1.30.0030.00518.05
8.1.20.0030.00618.19
8.1.10.0000.01018.20
8.1.00.0030.00819.98
8.0.300.0050.00321.81
8.0.290.0030.00617.25
8.0.280.0040.00418.71
8.0.270.0050.00317.50
8.0.260.0000.00717.12
8.0.250.0020.00517.33
8.0.240.0030.00717.32
8.0.230.0040.00417.29
8.0.220.0070.00017.38
8.0.210.0000.00817.30
8.0.200.0050.00317.34
8.0.190.0000.00817.30
8.0.180.0000.00917.33
8.0.170.0000.00917.28
8.0.160.0060.00317.29
8.0.150.0090.00017.29
8.0.140.0000.00917.27
8.0.130.0000.00613.74
8.0.120.0060.00317.29
8.0.110.0000.00817.18
8.0.100.0060.00317.38
8.0.90.0040.00417.45
8.0.80.0130.01017.34
8.0.70.0030.00617.38
8.0.60.0000.00817.30
8.0.50.0040.00417.23
8.0.30.0110.01417.45
8.0.20.0080.01217.42
8.0.10.0080.00017.50
8.0.00.0070.01317.06
7.4.330.0050.00015.00
7.4.320.0000.00717.12
7.4.300.0000.00817.15
7.4.290.0070.00017.01
7.4.280.0040.00417.09
7.4.270.0050.00517.03
7.4.260.0040.00413.89
7.4.250.0000.00816.88
7.4.240.0040.00317.06
7.4.230.0040.00417.11
7.4.220.0150.01017.14
7.4.210.0060.01217.09
7.4.200.0040.00417.18
7.4.190.0000.00716.81
7.4.160.0150.00716.82
7.4.150.0100.01017.40
7.4.140.0110.01117.86
7.4.130.0000.01817.08
7.4.120.0070.01116.96
7.4.110.0060.01317.14
7.4.100.0140.00317.08
7.4.90.0090.00916.90
7.4.80.0070.01819.39
7.4.70.0080.01216.93
7.4.60.0070.01017.03
7.4.50.0040.00416.97
7.4.40.0060.01322.77
7.4.30.0110.00716.88
7.4.00.0110.00815.30
7.3.330.0030.00313.63
7.3.320.0030.00313.59
7.3.310.0000.00716.68
7.3.300.0070.00016.82
7.3.290.0120.00316.74
7.3.280.0130.00716.74
7.3.270.0090.00917.40
7.3.260.0070.01816.63
7.3.250.0130.00916.95
7.3.240.0100.01016.73
7.3.230.0080.01216.80
7.3.210.0080.01416.81
7.3.200.0090.01519.39
7.3.190.0110.00716.81
7.3.180.0150.00316.95
7.3.170.0130.00316.96
7.3.160.0040.01417.03
7.3.120.0030.01415.46
7.2.330.0150.00316.95
7.2.320.0170.00817.07
7.2.310.0130.00716.86
7.2.300.0120.00617.14
7.2.290.0170.00017.14
7.2.00.0060.01019.45
7.1.200.0040.01116.23
7.1.100.0040.01118.66
7.1.70.0030.00617.59
7.1.60.0130.01319.32
7.1.50.0110.00717.24
7.1.00.0030.03322.49
7.0.200.0050.00316.97
7.0.140.0030.07722.35
7.0.100.0100.03720.41
7.0.90.0070.08020.12
7.0.80.0230.08020.18
7.0.70.0200.04320.19
7.0.60.0400.08020.12
7.0.50.0170.05720.60
7.0.40.0100.07320.35
7.0.30.0070.04320.33
7.0.20.0030.05720.30
7.0.10.0170.06720.28
7.0.00.0000.07720.32
5.6.280.0070.07321.02
5.6.250.0100.04720.67
5.6.240.0100.04720.60
5.6.230.0000.09020.61
5.6.220.0100.08020.57
5.6.210.0070.05020.63
5.6.200.0100.07321.07
5.6.190.0200.07321.21
5.6.180.0130.05021.13
5.6.170.0070.08321.05
5.6.160.0200.07721.05
5.6.150.0070.06321.03
5.6.140.0130.07721.08
5.6.130.0130.08020.95
5.6.120.0100.07721.04
5.6.110.0030.08721.06
5.6.100.0100.07321.10
5.6.90.0100.08021.01
5.6.80.0100.07720.47
5.6.70.0030.08020.37
5.6.60.0100.04020.34
5.6.50.0070.08020.36
5.6.40.0130.07720.53
5.6.30.0130.07720.41
5.6.20.0170.06720.39
5.6.10.0070.08020.35
5.6.00.0100.04720.44
5.5.380.0030.06720.36
5.5.370.0030.06720.38
5.5.360.0070.08020.38
5.5.350.0030.06320.44
5.5.340.0170.07720.87
5.5.330.0130.07720.84
5.5.320.0130.07720.83
5.5.310.0030.03720.98
5.5.300.0070.07320.93
5.5.290.0200.06720.67
5.5.280.0070.06320.91
5.5.270.0030.06720.77
5.5.260.0100.08720.94
5.5.250.0030.07720.78
5.5.240.0070.07320.30
5.5.230.0070.05320.34
5.5.220.0130.07320.04
5.5.210.0030.08320.18
5.5.200.0100.07320.30
5.5.190.0270.06020.17
5.5.180.0200.06720.25
5.5.160.0130.06320.03
5.5.150.0000.08720.12
5.5.140.0100.07320.14
5.5.130.0070.07320.17
5.5.120.0130.07720.13
5.5.110.0070.07720.03
5.5.100.0170.07720.20
5.5.90.0300.06020.21
5.5.80.0000.08020.11
5.5.70.0070.07020.20
5.5.60.0170.05320.01
5.5.50.0030.08720.08
5.5.40.0100.05320.20
5.5.30.0070.08020.11
5.5.20.0100.07320.19
5.5.10.0030.07720.17
5.5.00.0030.07020.17
5.4.450.0070.08319.29
5.4.440.0100.08019.54
5.4.430.0170.08019.22
5.4.420.0070.07719.21
5.4.410.0030.08019.09
5.4.400.0100.04019.11
5.4.390.0070.07719.10
5.4.380.0070.07019.28
5.4.370.0200.07019.22
5.4.360.0100.06019.11
5.4.350.0000.09319.15
5.4.340.0100.07319.29
5.4.320.0130.06718.93
5.4.310.0170.07319.10
5.4.300.0030.07719.25
5.4.290.0030.07719.08
5.4.280.0100.07718.93
5.4.270.0070.08018.90
5.4.260.0100.07718.96
5.4.250.0000.08319.18
5.4.240.0030.08018.91
5.4.230.0100.07718.92
5.4.220.0070.07319.08
5.4.210.0130.03718.90
5.4.200.0130.06719.17
5.4.190.0000.05018.95
5.4.180.0070.04718.95
5.4.170.0130.05019.09
5.4.160.0130.06719.03
5.4.150.0030.08019.26
5.4.140.0030.05316.30
5.4.130.0100.07016.43
5.4.120.0030.05016.37
5.4.110.0070.07716.48
5.4.100.0030.05016.34
5.4.90.0030.05016.51
5.4.80.0000.08016.48
5.4.70.0070.05316.48
5.4.60.0070.06716.49
5.4.50.0030.04316.51
5.4.40.0070.06716.50
5.4.30.0070.04716.34
5.4.20.0030.07716.32
5.4.10.0100.06316.34
5.4.00.0070.07315.82
5.3.290.0100.07314.76
5.3.280.0070.07314.64
5.3.270.0100.07314.75
5.3.260.0030.08314.66
5.3.250.0100.07314.66
5.3.240.0070.07014.66
5.3.230.0100.07014.71
5.3.220.0230.05014.58
5.3.210.0100.08014.59
5.3.200.0000.08014.75
5.3.190.0030.04314.66
5.3.180.0100.07314.67
5.3.170.0030.08014.77
5.3.160.0070.08014.72
5.3.150.0130.04014.65
5.3.140.0070.07714.68
5.3.130.0070.07714.71
5.3.120.0030.08014.70
5.3.110.0070.04714.78
5.3.100.0130.06714.08
5.3.90.0100.07714.03
5.3.80.0100.07014.16
5.3.70.0130.07014.00
5.3.60.0000.07714.01
5.3.50.0070.06014.09
5.3.40.0270.06014.02
5.3.30.0130.06314.04
5.3.20.0100.06713.60
5.3.10.0070.07013.66
5.3.00.0170.06313.73
5.2.170.0000.06712.34
5.2.160.0030.06312.34
5.2.150.0070.06012.34
5.2.140.0070.06012.34
5.2.130.0070.06012.34
5.2.120.0030.06012.34
5.2.110.0070.06312.34
5.2.100.0000.03312.34
5.2.90.0000.06712.34
5.2.80.0030.05712.34
5.2.70.0070.06312.34
5.2.60.0030.06012.34
5.2.50.0030.06312.34
5.2.40.0070.05712.34
5.2.30.0070.05712.34
5.2.20.0130.05712.34
5.2.10.0030.06012.34
5.2.00.0100.05312.34
5.1.60.0000.06012.34
5.1.50.0030.05312.34
5.1.40.0070.05312.34
5.1.30.0070.05712.34
5.1.20.0070.04312.34
5.1.10.0100.02012.34
5.1.00.0030.04312.34
5.0.50.0070.02012.34
5.0.40.0030.04312.34
5.0.30.0070.06012.34
5.0.20.0070.04012.34
5.0.10.0070.04012.34
5.0.00.0000.07012.34
4.4.90.0030.02012.34
4.4.80.0070.03012.34
4.4.70.0100.03012.34
4.4.60.0030.03712.34
4.4.50.0000.04012.34
4.4.40.0000.05012.34
4.4.30.0070.03312.34
4.4.20.0030.01312.34
4.4.10.0030.03012.34
4.4.00.0030.05312.34
4.3.110.0000.03712.34
4.3.100.0030.03012.34
4.3.90.0070.03312.34
4.3.80.0000.05712.34
4.3.70.0000.03712.34
4.3.60.0030.03312.34
4.3.50.0030.03012.34
4.3.40.0000.05312.34
4.3.30.0000.03712.34
4.3.20.0000.03712.34
4.3.10.0000.03712.34
4.3.00.0030.02012.34

preferences:
41.72 ms | 400 KiB | 5 Q