3v4l.org

run code in 300+ PHP versions simultaneously
<?php $emailAddr = "test@test.com"; // 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.70.0090.00617.00
8.3.60.0060.00918.96
8.3.50.0150.00322.24
8.3.40.0090.00619.29
8.3.30.0110.00419.46
8.3.20.0040.00420.71
8.3.10.0080.00022.00
8.3.00.0050.00318.30
8.2.180.0100.01017.13
8.2.170.0140.00722.96
8.2.160.0070.01020.83
8.2.150.0000.00724.18
8.2.140.0040.00424.66
8.2.130.0050.00326.16
8.2.120.0080.00020.20
8.2.110.0100.00022.22
8.2.100.0090.00318.41
8.2.90.0000.00919.60
8.2.80.0030.00517.99
8.2.70.0040.00418.25
8.2.60.0070.00218.28
8.2.50.0040.00418.25
8.2.40.0040.00418.59
8.2.30.0050.00318.57
8.2.20.0000.00818.20
8.2.10.0050.00318.36
8.2.00.0000.00918.06
8.1.280.0090.00925.92
8.1.270.0080.00024.09
8.1.260.0070.00026.35
8.1.250.0040.00428.09
8.1.240.0000.00922.38
8.1.230.0070.00319.30
8.1.220.0040.00417.80
8.1.210.0050.00318.77
8.1.200.0000.01117.72
8.1.190.0000.00817.60
8.1.180.0000.00918.10
8.1.170.0030.00619.04
8.1.160.0020.00522.17
8.1.150.0030.00619.14
8.1.140.0000.01117.73
8.1.130.0040.00418.14
8.1.120.0040.00417.78
8.1.110.0050.00417.84
8.1.100.0000.00717.77
8.1.90.0000.00817.83
8.1.80.0030.00517.73
8.1.70.0040.00417.65
8.1.60.0030.00517.83
8.1.50.0000.00817.73
8.1.40.0030.00517.80
8.1.30.0040.00417.88
8.1.20.0000.00817.87
8.1.10.0050.00617.95
8.1.00.0040.00417.64
8.0.300.0000.00818.77
8.0.290.0000.00717.13
8.0.280.0000.00718.66
8.0.270.0030.00317.41
8.0.260.0020.00517.39
8.0.250.0030.00317.28
8.0.240.0000.01017.27
8.0.230.0030.00617.27
8.0.220.0000.00717.28
8.0.210.0000.00717.19
8.0.200.0060.00017.25
8.0.190.0050.00217.25
8.0.180.0000.00717.35
8.0.170.0040.00417.16
8.0.160.0070.00017.24
8.0.150.0030.00517.14
8.0.140.0000.00817.20
8.0.130.0000.00713.88
8.0.120.0040.00417.02
8.0.110.0030.00517.32
8.0.100.0070.00017.23
8.0.90.0030.00517.21
8.0.80.0130.00617.20
8.0.70.0050.00317.12
8.0.60.0030.00517.12
8.0.50.0040.00417.33
8.0.30.0100.01417.39
8.0.20.0130.00617.46
8.0.10.0030.00517.22
8.0.00.0110.00817.05
7.4.330.0020.00515.00
7.4.320.0000.00616.86
7.4.300.0030.00316.80
7.4.290.0070.00016.84
7.4.280.0000.00816.92
7.4.270.0070.00016.90
7.4.260.0040.00416.85
7.4.250.0000.00816.88
7.4.240.0000.00716.87
7.4.230.0000.00816.78
7.4.220.0100.01016.93
7.4.210.0040.01116.93
7.4.200.0050.00216.93
7.4.160.0120.00316.86
7.4.150.0190.00317.40
7.4.140.0070.01217.86
7.4.130.0100.00717.08
7.4.120.0060.01116.85
7.4.110.0090.00916.92
7.4.100.0120.00617.03
7.4.90.0130.00617.06
7.4.80.0130.00719.39
7.4.70.0140.00316.84
7.4.60.0100.00716.81
7.4.50.0030.00316.97
7.4.40.0090.00916.79
7.4.30.0100.01016.84
7.4.00.0050.01215.39
7.3.330.0050.00013.60
7.3.320.0030.00313.52
7.3.310.0000.00716.86
7.3.300.0000.00716.52
7.3.290.0030.01916.62
7.3.280.0110.00616.74
7.3.270.0120.00617.40
7.3.260.0090.00916.63
7.3.250.0100.01016.84
7.3.240.0160.00616.81
7.3.230.0060.01316.91
7.3.210.0170.00716.66
7.3.200.0100.01319.39
7.3.190.0170.01316.71
7.3.180.0060.01016.64
7.3.170.0100.00716.59
7.3.160.0050.01116.84
7.3.120.0040.01115.03
7.3.110.0070.01315.05
7.3.100.0110.01115.36
7.3.90.0070.00714.96
7.3.80.0080.00314.89
7.3.70.0060.00614.89
7.3.60.0040.01215.19
7.3.50.0070.00315.21
7.3.40.0060.00614.87
7.3.30.0100.00715.03
7.3.20.0070.00716.80
7.3.10.0060.00316.98
7.3.00.0110.00016.81
7.2.330.0120.01216.88
7.2.320.0100.00716.94
7.2.310.0120.00616.82
7.2.300.0100.00716.88
7.2.290.0060.01317.09
7.2.250.0070.01315.38
7.2.240.0100.00715.21
7.2.230.0070.01015.54
7.2.220.0030.01415.38
7.2.210.0070.00715.32
7.2.200.0030.01215.30
7.2.190.0030.01415.44
7.2.180.0100.00415.10
7.2.170.0070.01015.36
7.2.160.0030.01215.28
7.2.150.0000.01116.99
7.2.140.0080.00417.08
7.2.130.0130.00317.15
7.2.120.0100.00717.12
7.2.110.0060.00617.27
7.2.100.0060.00917.32
7.2.90.0100.00317.29
7.2.80.0030.01317.22
7.2.70.0000.01817.35
7.2.60.0090.00917.24
7.2.50.0080.00817.11
7.2.40.0040.01117.26
7.2.30.0030.01317.22
7.2.20.0030.01317.21
7.2.10.0060.00916.93
7.2.00.0070.01018.41
7.1.330.0120.00616.25
7.1.320.0060.00815.83
7.1.310.0060.00316.29
7.1.300.0070.00316.23
7.1.290.0000.01715.83
7.1.280.0040.01116.02
7.1.270.0110.00316.07
7.1.260.0070.00716.07
7.1.250.0070.01116.27
7.1.240.0000.01416.15
7.1.230.0060.01015.95
7.1.220.0000.01316.07
7.1.210.0030.00916.12
7.1.200.0100.00615.93
7.1.190.0090.00915.91
7.1.180.0060.01016.23
7.1.170.0030.01316.17
7.1.160.0070.00716.18
7.1.150.0070.00716.26
7.1.140.0100.00316.11
7.1.130.0040.01115.89
7.1.120.0000.00816.12
7.1.110.0030.00916.26
7.1.100.0020.01017.29
7.1.90.0040.00715.98
7.1.80.0070.00716.25
7.1.70.0000.00916.88
7.1.60.0090.00917.77
7.1.50.0110.00716.55
7.1.40.0040.01116.21
7.1.30.0040.00715.80
7.1.20.0120.00015.93
7.1.10.0060.01016.26
7.1.00.0020.04219.34
7.0.330.0090.00315.66
7.0.320.0110.00315.78
7.0.310.0090.00015.52
7.0.300.0000.01215.78
7.0.290.0120.00315.70
7.0.280.0060.00615.77
7.0.270.0040.00715.64
7.0.260.0060.00615.53
7.0.250.0030.00715.84
7.0.240.0060.00615.75
7.0.230.0040.00815.75
7.0.220.0000.01015.75
7.0.210.0070.00715.87
7.0.200.0050.00716.34
7.0.190.0090.00615.84
7.0.180.0030.00615.81
7.0.170.0090.00315.83
7.0.160.0070.00715.71
7.0.150.0030.00915.73
7.0.140.0070.03818.99
7.0.130.0100.00715.61
7.0.120.0080.00015.55
7.0.110.0100.00315.88
7.0.100.0040.00415.67
7.0.90.0030.01315.84
7.0.80.0090.00615.60
7.0.70.0080.00415.89
7.0.60.0100.02017.72
7.0.50.0090.03216.89
7.0.40.0120.03317.07
7.0.30.0250.03516.93
7.0.20.0160.03617.00
7.0.10.0100.02217.10
7.0.00.0070.02916.97
5.6.400.0070.00714.55
5.6.390.0140.00014.84
5.6.380.0080.00814.55
5.6.370.0030.00914.41
5.6.360.0070.00714.32
5.6.350.0050.00914.55
5.6.340.0080.00314.78
5.6.330.0060.01014.43
5.6.320.0000.01414.32
5.6.310.0030.00714.88
5.6.300.0070.00714.75
5.6.290.0040.00814.31
5.6.280.0050.04117.94
5.6.270.0030.01014.61
5.6.260.0130.00314.53
5.6.250.0050.00514.80
5.6.240.0060.00614.69
5.6.230.0030.01314.62
5.6.220.0030.00614.52
5.6.210.0100.03817.75
5.6.200.0070.03216.40
5.6.190.0030.03117.54
5.6.180.0130.04717.45
5.6.170.0160.02317.50
5.6.160.0080.04017.63
5.6.150.0070.04716.48
5.6.140.0080.04116.48
5.6.130.0090.03816.41
5.6.120.0100.04217.96
5.6.110.0110.04517.93
5.6.100.0060.04517.77
5.6.90.0030.02817.91
5.6.80.0070.03617.28
5.6.70.1500.02317.62
5.6.60.0090.00314.50
5.6.50.0070.00714.45
5.6.40.0070.00714.67
5.6.30.0030.00714.55
5.6.20.0000.01314.47
5.6.10.0030.00914.22
5.6.00.0060.00314.45
5.5.380.0070.01114.71
5.5.370.0030.01214.57
5.5.360.0050.00814.17
5.5.350.0140.03717.50
5.5.340.0040.02616.17
5.5.330.0060.02517.35
5.5.320.0140.02817.48
5.5.310.0130.03017.46
5.5.300.0090.03816.25
5.5.290.0050.03516.26
5.5.280.0030.02917.79
5.5.270.0080.04517.71
5.5.260.0050.02617.63
5.5.250.0100.03617.58
5.5.240.0050.02017.38
5.5.230.0080.00614.16
5.5.220.0080.00614.29
5.5.210.0070.00314.45
5.5.200.0080.00614.65
5.5.190.0070.00314.29
5.5.180.0000.00914.29
5.5.170.0040.01114.64
5.5.160.0080.00814.27
5.5.150.0030.01014.29
5.5.140.0040.01214.44
5.5.130.0030.00814.21
5.5.120.0000.01314.48
5.5.110.0040.00414.15
5.5.100.0060.00914.52
5.5.90.0090.00014.45
5.5.80.0060.00914.45
5.5.70.0060.00914.23
5.5.60.0040.01214.52
5.5.50.0060.00914.49
5.5.40.0040.00414.25
5.5.30.0150.00014.37
5.5.20.0040.00814.24
5.5.10.0040.01414.58
5.5.00.0030.00914.49
5.4.450.0090.03015.50
5.4.440.0450.03215.29
5.4.430.0470.02815.40
5.4.420.0330.00215.28
5.4.410.0090.02915.16
5.4.400.0170.02615.13
5.4.390.0130.03015.05
5.4.380.0140.03615.04
5.4.370.0110.02614.92
5.4.360.0100.02014.93
5.4.350.0080.02211.53
5.4.340.0070.02111.66
5.4.330.0030.00611.32
5.4.320.0040.02211.80
5.4.310.0050.02311.98
5.4.300.0040.02311.91
5.4.290.0030.02511.91
5.4.280.0070.02111.85
5.4.270.0050.02211.75
5.4.260.0110.01711.81
5.4.250.0040.02311.93
5.4.240.0050.02211.88
5.4.230.0040.02511.93
5.4.220.0030.02311.94
5.4.210.0050.01911.83
5.4.200.0050.02211.95
5.4.190.0060.02111.88
5.4.180.0070.02111.86
5.4.170.0080.02011.85
5.4.160.0060.02411.77
5.4.150.0050.02511.87
5.4.140.0070.02011.79
5.4.130.0050.02111.74
5.4.120.0070.02011.72
5.4.110.0110.02011.57
5.4.100.0080.01911.66
5.4.90.0040.02411.69
5.4.80.0090.02111.76
5.4.70.0060.01911.69
5.4.60.0080.01711.72
5.4.50.0030.02111.51
5.4.40.0060.01911.75
5.4.30.0040.02111.54
5.4.20.0050.02311.75
5.4.10.0040.02011.72
5.4.00.0050.02011.44
5.3.290.0050.02511.89
5.3.280.0040.02411.85
5.3.270.0030.02511.86
5.3.260.0060.02211.86
5.3.250.0050.02311.86
5.3.240.0040.02311.86
5.3.230.0050.02211.85
5.3.220.0090.01911.84
5.3.210.0080.02011.84
5.3.200.0030.02211.84
5.3.190.0060.02111.84
5.3.180.0030.02111.84
5.3.170.0070.02011.84
5.3.160.0040.02111.84
5.3.150.0040.02111.84
5.3.140.0040.02111.84
5.3.130.0040.02311.83
5.3.120.0090.02711.83
5.3.110.0020.02611.83
5.3.100.0080.02011.57
5.3.90.0050.02411.56
5.3.80.0080.02011.56
5.3.70.0040.03111.56
5.3.60.0090.02011.55
5.3.50.0130.01611.53
5.3.40.0050.02011.53
5.3.30.0030.02411.51
5.3.20.0060.01911.40
5.3.10.0070.01911.38
5.3.00.0040.02311.37
5.2.170.0040.0319.29
5.2.160.0040.0319.30
5.2.150.0040.0329.29
5.2.140.0050.0319.29
5.2.130.0040.0309.25
5.2.120.0060.0279.25
5.2.110.0070.0279.25
5.2.100.0070.0269.25
5.2.90.0030.0319.25
5.2.80.0050.0309.25
5.2.70.0050.0309.25
5.2.60.0060.0299.21
5.2.50.0070.0289.17
5.2.40.0060.0279.16
5.2.30.0050.0299.13
5.2.20.0020.0329.13
5.2.10.0040.0299.01
5.2.00.0030.0318.86
5.1.60.0060.0308.15
5.1.50.0050.0338.15
5.1.40.0050.0248.13
5.1.30.0060.0258.48
5.1.20.0010.0308.50
5.1.10.0030.0278.23
5.1.00.0020.0288.23
5.0.50.0020.0226.72
5.0.40.0050.0186.57
5.0.30.0020.0336.39
5.0.20.0020.0216.35
5.0.10.0030.0216.33
5.0.00.0020.0326.32
4.4.90.0030.0154.78
4.4.80.0040.0144.75
4.4.70.0020.0174.76
4.4.60.0040.0154.75
4.4.50.0010.0174.77
4.4.40.0060.0224.72
4.4.30.0030.0154.76
4.4.20.0020.0164.85
4.4.10.0030.0154.85
4.4.00.0040.0244.76
4.3.110.0020.0174.67
4.3.100.0010.0174.66
4.3.90.0020.0154.64
4.3.80.0030.0244.62
4.3.70.0030.0144.63
4.3.60.0010.0164.63
4.3.50.0040.0144.63
4.3.40.0010.0254.57
4.3.30.0010.0173.39
4.3.20.0020.0163.36
4.3.10.0020.0183.31
4.3.00.0130.0276.57

preferences:
55.93 ms | 401 KiB | 5 Q