3v4l.org

run code in 300+ PHP versions simultaneously
<?php $emailAddr = "test@test.com"; $isDebug = true; // logic stolen shamelessly from an article in linuxjournal.com www.linuxjournal.com/article/9585 // return true if valid, false if not // set the error code to indicate the problem if not // 5 - no '@' found // 10 - email address name is longer than 64 // 15 - email domain name is longer than 64 // 20 - email address name begins or ends with a '.' // 25 - email address name has two consecutive dots '..' // 30 - invalid character in domain // 35 - domain has two consecutive dots '..' // 40 - invalid character in address name // 45 - domain not found in DNS $errorCode = 0; $isValid = true; $atIndex = strrpos($emailAddr, "@"); if (is_bool($atIndex) && !$atIndex) { if ($isDebug) print $emailAddr . "no '@' found<br>"; $errorCode = 5; $isValid = false; } else { $domain = substr($emailAddr, $atIndex+1); $local = substr($emailAddr, 0, $atIndex); $localLen = strlen($local); $domainLen = strlen($domain); if ($localLen < 1 || $localLen > 64) { if ($isDebug) print $emailAddr . " -local part length exceeded<br>"; $errorCode = 10; $isValid = false; } else if ($domainLen < 1 || $domainLen > 255) { if ($isDebug) print $emailAddr . " -domain part length exceeded<br>"; $errorCode = 15; $isValid = false; } else if ($local[0] == '.' || $local[$localLen-1] == '.') { if ($isDebug) print $emailAddr . " -local part starts or ends with '.'<br>"; $errorCode = 20; $isValid = false; } else if (preg_match('/\\.\\./', $local)) { if ($isDebug) print $emailAddr . " -local part has two consecutive dots<br>"; $errorCode = 25; $isValid = false; } else if (!preg_match('/^[A-Za-z0-9\\-\\.]+$/', $domain)) { if ($isDebug) print $emailAddr . " -character not valid in domain part<br>"; $errorCode = 30; $isValid = false; } else if (preg_match('/\\.\\./', $domain)) { if ($isDebug) print $emailAddr . " -domain part has two consecutive dots<br>"; $errorCode = 35; $isValid = false; } else if (!preg_match('/^(\\\\.|[A-Za-z0-9!#%&`_=\\/$\'*+?^{}|~.-])+$/', str_replace("\\\\","",$local))) { if ($isDebug) print $emailAddr . " -character not valid in local part unless local part is quoted<br>"; if (!preg_match('/^"(\\\\"|[^"])+"$/',str_replace("\\\\","",$local))) { $errorCode = 40; $isValid = false; } } if ($isValid && !(checkdnsrr($domain,"MX") || checkdnsrr($domain,"A"))){ if ($isDebug) { print $emailAddr . " -domain not found in DNS<br>"; $errorCode = 45; $isValid = false; } } } print $isValid; ?>

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.00719.00
8.3.50.0140.00522.17
8.3.40.0040.01119.29
8.3.30.0070.00719.33
8.3.20.0000.00820.71
8.3.10.0040.00422.35
8.3.00.0040.00418.30
8.2.180.0100.01317.13
8.2.170.0040.01122.96
8.2.160.0090.00620.77
8.2.150.0080.00024.18
8.2.140.0050.00324.66
8.2.130.0040.00426.16
8.2.120.0080.00021.16
8.2.110.0070.01120.64
8.2.100.0080.00418.34
8.2.90.0030.00518.13
8.2.80.0090.00019.36
8.2.70.0050.00518.25
8.2.60.0000.00918.00
8.2.50.0000.00818.13
8.2.40.0100.00318.41
8.2.30.0030.00518.56
8.2.20.0040.00418.02
8.2.10.0030.00618.44
8.2.00.0060.00318.09
8.1.280.0070.00725.92
8.1.270.0060.00323.86
8.1.260.0040.00426.35
8.1.250.0040.00428.09
8.1.240.0080.00322.25
8.1.230.0080.00422.82
8.1.220.0050.00319.07
8.1.210.0030.00618.77
8.1.200.0080.00017.73
8.1.190.0080.00017.60
8.1.180.0000.00822.23
8.1.170.0080.00017.72
8.1.160.0070.00022.18
8.1.150.0050.00219.16
8.1.140.0000.00817.79
8.1.130.0000.00718.09
8.1.120.0000.00817.72
8.1.110.0040.00417.69
8.1.100.0040.00417.81
8.1.90.0000.00817.73
8.1.80.0030.00517.72
8.1.70.0030.00317.64
8.1.60.0030.00617.82
8.1.50.0030.00617.81
8.1.40.0000.00817.80
8.1.30.0080.00017.96
8.1.20.0060.00317.93
8.1.10.0040.00417.87
8.1.00.0080.00017.74
8.0.300.0080.00018.77
8.0.290.0050.00317.30
8.0.280.0000.00718.66
8.0.270.0040.00417.37
8.0.260.0030.00317.34
8.0.250.0040.00417.34
8.0.240.0030.00517.25
8.0.230.0070.00017.26
8.0.220.0030.00317.09
8.0.210.0040.00417.18
8.0.200.0000.00717.07
8.0.190.0050.00217.07
8.0.180.0000.00717.09
8.0.170.0000.00817.20
8.0.160.0040.00417.11
8.0.150.0050.00216.98
8.0.140.0040.00417.14
8.0.130.0030.00313.64
8.0.120.0030.00617.16
8.0.110.0110.00017.05
8.0.100.0040.00417.07
8.0.90.0040.00417.08
8.0.80.0040.01417.11
8.0.70.0000.00817.18
8.0.60.0000.00817.21
8.0.50.0040.00417.22
8.0.30.0140.01117.38
8.0.20.0120.00617.55
8.0.10.0040.00417.15
8.0.00.0060.01217.14
7.4.330.0050.00015.43
7.4.320.0080.00016.82
7.4.300.0030.00316.80
7.4.290.0070.00016.84
7.4.280.0050.00316.93
7.4.270.0050.00316.89
7.4.260.0080.00016.92
7.4.250.0040.00416.81
7.4.240.0030.00516.89
7.4.230.0050.00316.96
7.4.220.0070.01116.88
7.4.210.0140.00017.02
7.4.200.0070.00016.73
7.4.160.0100.00616.95
7.4.150.0060.01217.40
7.4.140.0130.00517.86
7.4.130.0110.00716.66
7.4.120.0090.00816.85
7.4.110.0140.00316.80
7.4.100.0140.00316.94
7.4.90.0080.01116.84
7.4.80.0120.01219.39
7.4.70.0130.00316.93
7.4.60.0130.00616.88
7.4.50.0040.00416.92
7.4.40.0100.01316.95
7.4.30.0100.01017.02
7.4.00.0090.00915.04
7.3.330.0050.00013.74
7.3.320.0030.00313.49
7.3.310.0000.00816.71
7.3.300.0030.00616.69
7.3.290.0040.01116.71
7.3.280.0090.00816.56
7.3.270.0180.00017.40
7.3.260.0080.01317.10
7.3.250.0080.00916.81
7.3.240.0040.01416.72
7.3.230.0130.01016.85
7.3.210.0070.01116.68
7.3.200.0040.01819.39
7.3.190.0070.01216.88
7.3.180.0000.02016.82
7.3.170.0100.00616.78
7.3.160.0120.00616.89
7.3.120.0090.00515.00
7.3.110.0060.00915.20
7.3.100.0070.01015.20
7.3.90.0060.00315.18
7.3.80.0080.00414.76
7.3.70.0110.00415.15
7.3.60.0030.00715.10
7.3.50.0040.01115.04
7.3.40.0000.01215.18
7.3.30.0050.00315.15
7.3.20.0060.00916.83
7.3.10.0060.00617.13
7.3.00.0000.01516.73
7.2.330.0120.00616.89
7.2.320.0100.00716.79
7.2.310.0070.01116.86
7.2.300.0100.00616.70
7.2.290.0080.00817.15
7.2.250.0060.01115.07
7.2.240.0060.01215.34
7.2.230.0060.00615.53
7.2.220.0080.00415.24
7.2.210.0090.00615.17
7.2.200.0030.00615.42
7.2.190.0070.00415.24
7.2.180.0030.01015.41
7.2.170.0030.00715.38
7.2.60.0060.00917.00
7.2.00.0000.01519.79
7.1.330.0000.01316.05
7.1.320.0030.01016.02
7.1.310.0000.01216.22
7.1.300.0110.00416.01
7.1.290.0030.00915.89
7.1.280.0030.00616.21
7.1.270.0070.00716.02
7.1.260.0050.00515.99
7.1.200.0070.00715.99
7.1.100.0060.00918.41
7.1.70.0000.01417.20
7.1.60.0070.01119.70
7.1.50.0200.00317.07
7.1.00.0000.08022.46
7.0.200.0030.00617.11
7.0.140.0000.07722.06
7.0.60.0030.04020.10
7.0.50.0130.07717.95
7.0.40.0170.07320.15
7.0.30.0330.06320.32
7.0.20.0330.07020.43
7.0.10.0100.08720.22
7.0.00.0100.08720.39
5.6.280.0070.07320.89
5.6.210.0130.05020.72
5.6.200.0100.06718.21
5.6.190.0070.08320.67
5.6.180.0270.07320.68
5.6.170.0230.08320.80
5.6.160.0030.08320.65
5.6.150.0000.09018.27
5.6.140.0030.06318.43
5.6.130.0000.06018.27
5.6.120.0200.04021.20
5.6.110.0100.08021.20
5.6.100.0000.04720.96
5.6.90.0100.07321.05
5.6.80.0100.08020.46
5.5.350.0170.04020.43
5.5.340.0070.03718.07
5.5.330.0100.07720.22
5.5.320.0000.04320.36
5.5.310.0330.06320.42
5.5.300.0030.08018.15
5.5.290.0070.07018.04
5.5.280.0130.03720.85
5.5.270.0070.08720.87
5.5.260.0030.05720.90
5.5.250.0130.08320.63
5.5.240.0130.07720.20
5.4.450.0570.05719.29
5.4.440.0230.06019.66
5.4.430.0230.06019.65
5.4.420.0230.07019.55
5.4.410.0270.07019.54
5.4.400.0170.07319.46
5.4.390.0200.07019.46
5.4.380.0400.06718.73
5.4.370.1130.06018.71
5.4.360.0400.05318.86
5.4.350.0430.05318.81
5.4.340.0330.05318.60
5.4.320.0090.03912.57
5.4.310.0070.03712.56
5.4.300.0080.03412.57
5.4.290.0080.03612.56
5.4.280.0050.03712.46
5.4.270.0070.03612.46
5.4.260.0110.03412.46
5.4.250.0080.03812.46
5.4.240.0070.03612.46
5.4.230.0010.04312.45
5.4.220.0040.04112.45
5.4.210.0050.03612.45
5.4.200.0070.03612.46
5.4.190.0100.03212.45
5.4.180.0060.03712.45
5.4.170.0060.03912.46
5.4.160.0060.03712.45
5.4.150.0060.03612.45
5.4.140.0060.04212.13
5.4.130.0070.03412.13
5.4.120.0080.03612.08
5.4.110.0040.03912.07
5.4.100.0060.03712.08
5.4.90.0040.03912.07
5.4.80.0110.04112.07
5.4.70.0070.03612.07
5.4.60.0090.03212.07
5.4.50.0050.03612.07
5.4.40.0070.04612.06
5.4.30.0060.04412.06
5.4.20.0050.03612.05
5.4.10.0040.03712.05
5.4.00.0090.03211.54
5.3.290.0030.04112.82
5.3.280.0050.03812.75
5.3.270.0050.04312.76
5.3.260.0060.03912.76
5.3.250.0080.03512.76
5.3.240.0100.04812.76
5.3.230.0080.03712.75
5.3.220.0110.03612.72
5.3.210.0060.04212.72
5.3.200.0070.03512.72
5.3.190.0060.03712.72
5.3.180.0050.03812.71
5.3.170.0060.03612.71
5.3.160.0080.03512.71
5.3.150.0070.03712.72
5.3.140.0060.03612.71
5.3.130.0040.04012.70
5.3.120.0030.04212.70
5.3.110.0080.03712.70
5.3.100.0030.03912.19
5.3.90.0050.03812.17
5.3.80.0070.04112.16
5.3.70.0040.03812.18
5.3.60.0050.03812.15
5.3.50.0050.04012.10
5.3.40.0050.04612.09
5.3.30.0060.03512.06
5.3.20.0020.03911.84
5.3.10.0090.03311.80
5.3.00.0050.03811.79
5.2.170.0050.0309.29
5.2.160.0040.0319.29
5.2.150.0030.0339.29
5.2.140.0040.0329.29
5.2.130.0070.0279.25
5.2.120.0030.0299.25
5.2.110.0030.0319.26
5.2.100.0030.0329.25
5.2.90.0040.0309.25
5.2.80.0030.0339.24
5.2.70.0020.0339.25
5.2.60.0050.0359.21
5.2.50.0050.0309.18
5.2.40.0060.0289.16
5.2.30.0020.0339.13
5.2.20.0040.0299.13
5.2.10.0030.0309.01
5.2.00.0050.0308.86
5.1.60.0070.0218.16
5.1.50.0040.0298.15
5.1.40.0050.0248.13
5.1.30.0080.0238.47
5.1.20.0030.0278.50
5.1.10.0060.0248.23
5.1.00.0080.0228.23
5.0.50.0030.0216.72
5.0.40.0010.0236.57
5.0.30.0030.0336.39
5.0.20.0070.0236.35
5.0.10.0040.0206.32
5.0.00.0030.0326.32
4.4.90.0020.0174.78
4.4.80.0040.0144.76
4.4.70.0030.0154.76
4.4.60.0050.0144.76
4.4.50.0020.0174.77
4.4.40.0050.0244.71
4.4.30.0040.0144.76
4.4.20.0040.0144.85
4.4.10.0030.0164.85
4.4.00.0020.0264.76
4.3.110.0030.0164.67
4.3.100.0040.0144.66
4.3.90.0010.0164.63
4.3.80.0010.0274.62
4.3.70.0060.0114.63
4.3.60.0030.0144.63
4.3.50.0040.0144.63
4.3.40.0030.0244.57
4.3.30.0030.0153.39
4.3.20.0030.0203.36
4.3.10.0020.0163.32
4.3.00.0100.0337.82

preferences:
49.53 ms | 401 KiB | 5 Q